-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yaml: implement basic Swagger/OpenAPI subparser #3245
Changes from all commits
36a38b0
9f2d7e7
ec41b0d
ca51085
c4160ee
b94e5c7
1d0e1ec
876afe2
d475cb2
4098994
97915e7
e44cbe0
60d16fc
ddf8f57
f4bc443
370796b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--language-force=openapi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/sample/other/path input.yaml /^ \/sample\/other\/path:$/;" p | ||
/sample/path input.yaml /^ \/sample\/path:$/;" p | ||
Body1 input.yaml /^ Body1:$/;" B | ||
Body2 input.yaml /^ Body2:$/;" B | ||
Callback1 input.yaml /^ Callback1: {}$/;" c | ||
Callback2 input.yaml /^ Callback2: {}$/;" c | ||
CustomHeader input.yaml /^ CustomHeader:$/;" P | ||
Example1 input.yaml /^ Example1:$/;" e | ||
Example2 input.yaml /^ Example2:$/;" e | ||
Header1 input.yaml /^ Header1:$/;" h | ||
Header2 input.yaml /^ Header2:$/;" h | ||
Link1 input.yaml /^ Link1: {}$/;" l | ||
Link2 input.yaml /^ Link2: {}$/;" l | ||
NullableField input.yaml /^ NullableField:$/;" d | ||
NullableFieldStringEnum input.yaml /^ NullableFieldStringEnum:$/;" d | ||
PathItem1 input.yaml /^ PathItem1: {}$/;" A | ||
PathItem2 input.yaml /^ PathItem2: {}$/;" A | ||
Response1 input.yaml /^ Response1:$/;" R | ||
Response2 input.yaml /^ Response2:$/;" R | ||
SSchema1 input.yaml /^ SSchema1:$/;" C | ||
SSchema2 input.yaml /^ SSchema2:$/;" C | ||
SomeApiKey input.yaml /^ - SomeApiKey:$/;" s | ||
android_handler input.yaml /^ - name: android_handler$/;" t | ||
description input.yaml /^ description: test$/;" I | ||
http://example.com input.yaml /^ url: http:\/\/example.com$/;" D | ||
http://example.com input.yaml /^ - url: http:\/\/example.com$/;" S | ||
http://example2.com input.yaml /^ - url: http:\/\/example2.com$/;" S | ||
ios_handler input.yaml /^ - name: ios_handler$/;" t | ||
title input.yaml /^ title: test$/;" I | ||
version input.yaml /^ version: '1.0'$/;" I |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: test | ||
description: test | ||
version: '1.0' | ||
|
||
servers: | ||
- url: http://example.com | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about tagging the URLs under servers? |
||
description: production | ||
- url: http://example2.com | ||
description: testing | ||
|
||
paths: | ||
/sample/path: | ||
get: | ||
summary: simple handler | ||
responses: {} | ||
|
||
/sample/other/path: | ||
get: | ||
responses: {} | ||
post: | ||
summary: xxx | ||
responses: {} | ||
|
||
components: | ||
schemas: | ||
NullableField: | ||
type: object | ||
properties: {} | ||
NullableFieldStringEnum: | ||
type: object | ||
properties: {} | ||
|
||
parameters: | ||
CustomHeader: | ||
in: header | ||
name: X-Custom-Header | ||
required: false | ||
schema: | ||
type: string | ||
|
||
responses: | ||
Response1: | ||
description: Payment Required | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: {} | ||
Response2: | ||
description: smth 2 | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: {} | ||
examples: | ||
Example1: | ||
summary: xxx | ||
value: yyyyy | ||
Example2: | ||
summary: xxx | ||
value: yyyyy | ||
requestBodies: | ||
Body1: | ||
description: bla bla bla | ||
content: | ||
application/json: | ||
schema: | ||
type: string | ||
Body2: | ||
description: bla bla bla | ||
content: | ||
application/json: | ||
schema: | ||
type: integer | ||
headers: | ||
Header1: | ||
schema: | ||
type: string | ||
Header2: | ||
schema: | ||
type: string | ||
securitySchemes: | ||
SSchema1: | ||
type: http | ||
scheme: basic | ||
SSchema2: | ||
type: http | ||
scheme: basic | ||
links: | ||
Link1: {} | ||
Link2: {} | ||
callbacks: | ||
Callback1: {} | ||
Callback2: {} | ||
# pathItems is allowed in 3.1.0 | ||
pathItems: | ||
PathItem1: {} | ||
PathItem2: {} | ||
|
||
|
||
|
||
security: | ||
- {} | ||
- SomeApiKey: | ||
- foo:read | ||
- foo:write | ||
|
||
tags: | ||
- name: android_handler | ||
description: Handler for Android clients | ||
- name: ios_handler | ||
description: Handler for iOS clients | ||
|
||
externalDocs: | ||
description: some docs | ||
url: http://example.com |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--language-force=openapi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/sample/other/path input.yaml /^ \/sample\/other\/path:$/;" p | ||
/sample/path input.yaml /^ \/sample\/path:$/;" p | ||
Param1 input.yaml /^ Param1:$/;" P | ||
Param2 input.yaml /^ Param2:$/;" P | ||
PolymorphicInteger input.yaml /^ PolymorphicInteger:$/;" d | ||
PolymorphicString input.yaml /^ PolymorphicString:$/;" d | ||
Response1 input.yaml /^ Response1:$/;" R | ||
Response2 input.yaml /^ Response2:$/;" R | ||
description input.yaml /^ description: test$/;" I | ||
title input.yaml /^ title: test$/;" I | ||
version input.yaml /^ version: '1.0'$/;" I |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
swagger: '2.0' | ||
info: | ||
description: test | ||
title: test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about tagging the title? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it makes sense to tag all user-defined entities, then ok.
I don't think the following entities worth adding tags (too minor IMHO):
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also the items of "components": https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-6 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way I wrote is wrong. |
||
version: '1.0' | ||
host: example.com | ||
|
||
paths: | ||
/sample/path: | ||
post: | ||
description: test | ||
responses: | ||
200: | ||
description: xxx | ||
|
||
/sample/other/path: | ||
get: | ||
description: smth | ||
responses: | ||
200: | ||
description: xxx | ||
|
||
definitions: | ||
PolymorphicString: | ||
type: object | ||
required: | ||
- type | ||
- value | ||
additionalProperties: false | ||
properties: | ||
type: | ||
type: string | ||
value: | ||
type: string | ||
|
||
PolymorphicInteger: | ||
type: object | ||
required: | ||
- type | ||
- value | ||
additionalProperties: false | ||
properties: | ||
type: | ||
type: string | ||
value: | ||
type: integer | ||
|
||
parameters: | ||
Param1: | ||
name: test1 | ||
in: query | ||
type: boolean | ||
|
||
Param2: | ||
name: test2 | ||
in: query | ||
type: boolean | ||
|
||
responses: | ||
Response1: | ||
description: aaa | ||
|
||
Response2: | ||
description: bbb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about tagging the title?