-
Notifications
You must be signed in to change notification settings - Fork 54
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 #1547 from ballerina-platform/1.8.x
Sync master with 1.8.x branch
- Loading branch information
Showing
11 changed files
with
639 additions
and
101 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
310 changes: 239 additions & 71 deletions
310
...ervice/src/main/java/io/ballerina/openapi/converter/service/OpenAPIRequestBodyMapper.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
182 changes: 182 additions & 0 deletions
182
...api-cli/src/test/resources/ballerina-to-openapi/expected_gen/request_body/union_type.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,182 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: PayloadV | ||
version: 0.0.0 | ||
servers: | ||
- url: "{server}:{port}/payloadV" | ||
variables: | ||
server: | ||
default: http://localhost | ||
port: | ||
default: "0" | ||
paths: | ||
/path: | ||
post: | ||
operationId: postPath | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ABC' | ||
responses: | ||
"202": | ||
description: Accepted | ||
/path1: | ||
post: | ||
operationId: postPath1 | ||
responses: | ||
"202": | ||
description: Accepted | ||
/path2: | ||
post: | ||
operationId: postPath2 | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ABC' | ||
application/xml: | ||
schema: {} | ||
responses: | ||
"202": | ||
description: Accepted | ||
/path3: | ||
post: | ||
operationId: postPath3 | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
oneOf: | ||
- $ref: '#/components/schemas/ABC' | ||
- $ref: '#/components/schemas/Remote' | ||
application/xml: | ||
schema: {} | ||
responses: | ||
"202": | ||
description: Accepted | ||
/path4: | ||
post: | ||
operationId: postPath4 | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ABC' | ||
text/plain: | ||
schema: | ||
type: string | ||
application/xml: | ||
schema: {} | ||
responses: | ||
"202": | ||
description: Accepted | ||
/path5: | ||
post: | ||
operationId: postPath5 | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
oneOf: | ||
- $ref: '#/components/schemas/ABC' | ||
- type: integer | ||
format: int64 | ||
responses: | ||
"202": | ||
description: Accepted | ||
/path6: | ||
post: | ||
operationId: postPath6 | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
type: integer | ||
format: int64 | ||
text/plain: | ||
schema: | ||
type: string | ||
responses: | ||
"202": | ||
description: Accepted | ||
/path7: | ||
post: | ||
operationId: postPath7 | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
oneOf: | ||
- type: object | ||
additionalProperties: {} | ||
- type: array | ||
items: | ||
type: integer | ||
format: int64 | ||
responses: | ||
"202": | ||
description: Accepted | ||
/path8: | ||
post: | ||
operationId: postPath8 | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
additionalProperties: | ||
type: integer | ||
format: int64 | ||
text/plain: | ||
schema: | ||
type: string | ||
responses: | ||
"202": | ||
description: Accepted | ||
/path9: | ||
post: | ||
operationId: postPath9 | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
oneOf: | ||
- type: object | ||
additionalProperties: | ||
type: integer | ||
format: int64 | ||
- type: object | ||
additionalProperties: | ||
type: string | ||
responses: | ||
"202": | ||
description: Accepted | ||
components: | ||
schemas: | ||
ABC: | ||
required: | ||
- id | ||
- name | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
name: | ||
type: string | ||
Remote: | ||
required: | ||
- host | ||
- ip | ||
- port | ||
type: object | ||
properties: | ||
host: | ||
type: string | ||
port: | ||
type: integer | ||
format: int64 | ||
ip: | ||
type: string | ||
description: Presents a read-only view of the remote address. |
40 changes: 40 additions & 0 deletions
40
openapi-cli/src/test/resources/ballerina-to-openapi/request_body/union_type.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,40 @@ | ||
import ballerina/http; | ||
|
||
public type ABC record { | ||
int id; | ||
string name; | ||
}; | ||
type UnionType ABC|xml; | ||
|
||
service /payloadV on new http:Listener(0) { | ||
resource function post path(ABC? payload) { | ||
} | ||
//This needs to be fixed with separated PR | ||
resource function post path1(UnionType payload) { | ||
} | ||
resource function post path2(ABC|xml payload) { | ||
} | ||
resource function post path3(ABC|http:Remote|xml? payload) { | ||
} | ||
resource function post path4(@http:Payload ABC|string|xml payload) { | ||
} | ||
//oneOF- scenarios for application/json | ||
resource function post path5(@http:Payload ABC|int payload) { | ||
} | ||
resource function post path6(@http:Payload int|string payload) { | ||
} | ||
resource function post path7(@http:Payload map<json>|int[] payload) { | ||
} | ||
resource function post path8(@http:Payload map<int>|string payload) { | ||
} | ||
resource function post path9(@http:Payload map<int>|map<string> payload) { | ||
} | ||
|
||
// //negative - skip | ||
// resource function post path10(ABC|string payload) { | ||
// } | ||
// resource function post path11(int|string payload) { | ||
// } | ||
// resource function post path12(map<int>|string payload) { | ||
// } | ||
} |
29 changes: 29 additions & 0 deletions
29
...i-cli/src/test/resources/generators/service/ballerina/multiPathParamWithExtensionType.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,29 @@ | ||
import ballerina/http; | ||
|
||
listener http:Listener ep0 = new (80, config = {host: "petstore.openapi.io"}); | ||
|
||
service /v1 on ep0 { | ||
# Info for a specific pet | ||
# | ||
# + spreadsheetId - The id of the pet to retrieve | ||
# + sheetidCopyto - The id of the pet to retrieve | ||
# + return - returns can be any of following types | ||
# http:Ok (Expected response to a valid request) | ||
# http:Response (unexpected error) | ||
resource function get v4/spreadsheets/[int spreadsheetId]/sheets/[string sheetidCopyto]() returns http:Ok|http:Response|error { | ||
if !sheetidCopyto.endsWith(":copyTo") { | ||
return error("bad URL"); | ||
} | ||
string sheetId = sheetidCopyto.substring(0, sheetidCopyto.length() - 6); | ||
} | ||
# Get the details of the specified field | ||
# | ||
# + idJson - Field ID | ||
# + return - Successful response | ||
resource function get 'field/[string idJson]() returns http:Ok|error { | ||
if !idJson.endsWith(".json") { | ||
return error("bad URL"); | ||
} | ||
string id = idJson.substring(0, idJson.length() - 4); | ||
} | ||
} |
Oops, something went wrong.