-
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 #1771 from ballerina-platform/query-name-support
Add OpenAPI mapping support for query annotation with name field
- Loading branch information
Showing
9 changed files
with
277 additions
and
12 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
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
174 changes: 174 additions & 0 deletions
174
openapi-cli/src/test/resources/ballerina-to-openapi/expected_gen/query/query_scenario10.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,174 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: PayloadV | ||
version: 0.0.0 | ||
servers: | ||
- url: "{server}:{port}/payloadV" | ||
variables: | ||
server: | ||
default: http://localhost | ||
port: | ||
default: "9090" | ||
paths: | ||
/query: | ||
get: | ||
operationId: getQuery | ||
parameters: | ||
- name: query0 | ||
in: query | ||
schema: | ||
type: string | ||
default: "" | ||
- name: q1 | ||
in: query | ||
schema: | ||
type: string | ||
- name: query2 | ||
in: query | ||
schema: | ||
type: array | ||
items: | ||
type: string | ||
default: [] | ||
- name: query3 | ||
in: query | ||
schema: | ||
type: array | ||
items: | ||
type: string | ||
default: | ||
- one | ||
- two | ||
- three | ||
- name: query4 | ||
in: query | ||
schema: | ||
type: array | ||
items: | ||
type: integer | ||
format: int64 | ||
default: | ||
- 1 | ||
- 2 | ||
- 3 | ||
- name: query5 | ||
in: query | ||
schema: | ||
type: array | ||
items: | ||
type: number | ||
format: float | ||
default: | ||
- 1 | ||
- 2.3 | ||
- 4.56 | ||
- name: query6 | ||
in: query | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
default: | ||
name: John | ||
city: London | ||
- name: query7 | ||
in: query | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
default: | ||
- name: John | ||
age: "25" | ||
- name: David | ||
age: "30" | ||
- name: query8 | ||
in: query | ||
content: | ||
application/json: | ||
schema: | ||
allOf: | ||
- $ref: "#/components/schemas/Record" | ||
default: | ||
name: John | ||
address: | ||
number: 14/7 | ||
streetName: 2nd cross street | ||
city: London | ||
- name: query9 | ||
in: query | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
additionalProperties: | ||
type: number | ||
format: float | ||
default: {} | ||
- name: query10 | ||
in: query | ||
schema: | ||
type: array | ||
items: | ||
type: boolean | ||
default: | ||
- true | ||
- false | ||
- true | ||
responses: | ||
"200": | ||
description: Ok | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/ErrorPayload" | ||
components: | ||
schemas: | ||
ErrorPayload: | ||
required: | ||
- message | ||
- method | ||
- path | ||
- reason | ||
- status | ||
- timestamp | ||
type: object | ||
properties: | ||
timestamp: | ||
type: string | ||
status: | ||
type: integer | ||
format: int64 | ||
reason: | ||
type: string | ||
message: | ||
type: string | ||
path: | ||
type: string | ||
method: | ||
type: string | ||
Record: | ||
required: | ||
- address | ||
- name | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
address: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
additionalProperties: false |
31 changes: 31 additions & 0 deletions
31
openapi-cli/src/test/resources/ballerina-to-openapi/query/query_scenario10.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,31 @@ | ||
import ballerina/http; | ||
|
||
listener http:Listener helloEp = new (9090); | ||
|
||
type Record record {| | ||
string name; | ||
map<string> address; | ||
|}; | ||
|
||
const query1 = "query1"; | ||
|
||
service /payloadV on helloEp { | ||
|
||
resource function get query( | ||
@http:Query{name: "query0"} string q0 = "", | ||
@http:Query{name: query1} string q1 = string `"John"`, | ||
@http:Query{name: "query2"} string[] q2 = [], | ||
@http:Query{name: "query3"} string[] q3 = ["one", "two", "three"], | ||
@http:Query{name: "query4"} int[] q4 = [1, 2, 3], | ||
@http:Query{name: "query5"} float[] q5 = [1, 2.3, 4.56], | ||
@http:Query{name: "query6"} map<string> q6 = {"name": "John", "city": "London"}, | ||
@http:Query{name: "query7"} map<string>[] q7 = [{"name": "John", age: "25"}, | ||
{name: "David", age: "30"}], | ||
@http:Query{name: "query8" } Record q8 = {name: "John", address: {number: "14/7", | ||
streetName: "2nd cross street", city: "London"}}, | ||
@http:Query{name: "query9"} map<float> q9 = {}, | ||
@http:Query{name: "query10"} boolean[] q10 = [true, false, true] | ||
) returns string { | ||
return "new"; | ||
} | ||
} |
Oops, something went wrong.