-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1421 from lnash94/internal_361_1.6.x
[1.6.x] Add fix for handling `additionalProperties` field in requestBody in service generation
- Loading branch information
Showing
10 changed files
with
217 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...cli/src/test/resources/generators/service/ballerina/requestBody/additional_prop_types.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
public type Mailing_AddContact_body record { | ||
string name?; | ||
}; | ||
|
||
public type Mailing_AddContact_body_1 record { | ||
string name?; | ||
}; | ||
|
||
public type Mailing_AddContact_body_2 record {| | ||
string name?; | ||
int...; | ||
|}; | ||
|
||
public type MailingViewModel record {| | ||
string? name?; | ||
string? email?; | ||
boolean optPhoneNumber?; | ||
string? phoneNumber?; | ||
string? motivoRecusa?; | ||
|}; | ||
|
||
public type Mailing_AddContact_body_3 record {| | ||
string name?; | ||
MailingViewModel...; | ||
|}; | ||
|
||
public type HistoricoSimulacaoViewModel record {| | ||
string? email?; | ||
string? data?; | ||
string? step?; | ||
string? descricao?; | ||
|}; |
24 changes: 24 additions & 0 deletions
24
...i-cli/src/test/resources/generators/service/ballerina/requestBody/additional_property.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import ballerina/http; | ||
|
||
listener http:Listener ep0 = new (9090, config = {host: "localhost"}); | ||
|
||
service / on ep0 { | ||
# Description | ||
# | ||
# + payload - parameter description | ||
# + return - Success | ||
resource function post api/HistoricoSimulacao/AddHistorico(@http:Payload record {|string...;|}|record {|HistoricoSimulacaoViewModel...;|}|record {|record {|string...;|}...;|} payload) returns http:Ok { | ||
} | ||
# Description | ||
# | ||
# + payload - parameter description | ||
# + return - Success | ||
resource function put api/Mailing/AddContact(@http:Payload Mailing_AddContact_body|Mailing_AddContact_body_1 payload) returns http:Ok { | ||
} | ||
# Description | ||
# | ||
# + payload - parameter description | ||
# + return - Success | ||
resource function post api/Mailing/AddContact(@http:Payload Mailing_AddContact_body_2|Mailing_AddContact_body_3 payload) returns http:Ok { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
...pi-cli/src/test/resources/generators/service/swagger/requestBody/additional_property.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: APITest | ||
contact: | ||
name: Samuel Apolion Benevenuto | ||
version: v1 | ||
paths: | ||
/api/HistoricoSimulacao/AddHistorico: | ||
post: | ||
tags: | ||
- HistoricoSimulacao | ||
requestBody: | ||
content: | ||
application/json-patch+json: | ||
schema: | ||
type: object | ||
additionalProperties: #addtionalProperties with primitive types | ||
type: string | ||
application/json: | ||
schema: | ||
type: object | ||
additionalProperties: #addtionalProperties with reference | ||
$ref: '#/components/schemas/HistoricoSimulacaoViewModel' | ||
application/path+json: | ||
schema: | ||
type: object | ||
additionalProperties: #addtionalProperties with reference | ||
type: object | ||
additionalProperties: | ||
type: string | ||
responses: | ||
'200': | ||
description: Success | ||
x-auth-type: None | ||
x-throttling-tier: Unlimited | ||
/api/Mailing/AddContact: | ||
post: | ||
tags: | ||
- Mailing | ||
requestBody: | ||
content: | ||
application/json-patch+json: | ||
schema: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
additionalProperties: #Object schema with properties and additionalProperties fields | ||
type: integer | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
additionalProperties: #Object schema with properties and additionalProperties with reference fields | ||
$ref: '#/components/schemas/MailingViewModel' | ||
responses: | ||
'200': | ||
description: Success | ||
x-auth-type: None | ||
x-throttling-tier: Unlimited | ||
put: | ||
tags: | ||
- Mailing | ||
requestBody: | ||
content: | ||
application/json-patch+json: | ||
schema: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
additionalProperties: #Object schema with properties and additionalProperties fields | ||
allOf: | ||
- type: integer | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
additionalProperties: #Object schema with properties and additionalProperties with reference fields | ||
oneOf: | ||
- type: integer | ||
- $ref: '#/components/schemas/MailingViewModel' | ||
responses: | ||
'200': | ||
description: Success | ||
x-auth-type: None | ||
x-throttling-tier: Unlimited | ||
components: | ||
schemas: | ||
HistoricoSimulacaoViewModel: | ||
type: object | ||
properties: | ||
email: | ||
type: string | ||
nullable: true | ||
data: | ||
type: string | ||
format: date-time | ||
nullable: true | ||
step: | ||
type: string | ||
nullable: true | ||
descricao: | ||
type: string | ||
nullable: true | ||
additionalProperties: false | ||
MailingViewModel: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
nullable: true | ||
email: | ||
type: string | ||
nullable: true | ||
optPhoneNumber: | ||
type: boolean | ||
phoneNumber: | ||
type: string | ||
nullable: true | ||
motivoRecusa: | ||
type: string | ||
nullable: true | ||
additionalProperties: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters