-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml: implement basic Swagger/OpenAPI subparser
The parser is able to parse both Swagger 2.0 and Openapi 3.0.x. The code is partly based on ansible playbook parser. It was tested using the following vim's TagBar parser declaration: let g:tagbar_type_yaml = { \ 'ctagstype': 'openapi', \ 'kinds': [ \ 'p:path', \ 'd:schema', \ 'P:parameter', \ 'R:response', \ ] \ }
- Loading branch information
Showing
13 changed files
with
507 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--language-force=openapi |
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,7 @@ | ||
/sample/other/path input.yaml /^ \/sample\/other\/path:$/;" p | ||
/sample/path input.yaml /^ \/sample\/path:$/;" p | ||
CustomHeader input.yaml /^ CustomHeader:$/;" P | ||
NullableField input.yaml /^ NullableField:$/;" d | ||
NullableFieldStringEnum input.yaml /^ NullableFieldStringEnum:$/;" d | ||
Response1 input.yaml /^ Response1:$/;" R | ||
Response2 input.yaml /^ Response2:$/;" R |
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 @@ | ||
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,55 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: test | ||
description: test | ||
version: '1.0' | ||
|
||
servers: | ||
- url: http://example.com | ||
description: production | ||
|
||
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: {} |
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 @@ | ||
--language-force=openapi |
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,8 @@ | ||
/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 |
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 @@ | ||
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,64 @@ | ||
swagger: '2.0' | ||
info: | ||
description: test | ||
title: test | ||
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 |
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
Oops, something went wrong.