-
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.
Add test cases for Swagger V2 and OpenAPI 3.0.0
- Loading branch information
1 parent
ad24c75
commit 4befa98
Showing
5 changed files
with
785 additions
and
0 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
174 changes: 174 additions & 0 deletions
174
openapi-cli/src/test/resources/cmd/sanitize/openapi_2.0.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 @@ | ||
swagger: "2.0" | ||
info: | ||
title: Api V1 | ||
version: 0.0.0 | ||
host: "localhost:8080" | ||
basePath: "/api/v1" | ||
schemes: | ||
- http | ||
paths: | ||
/albums: | ||
get: | ||
tags: | ||
- albums | ||
operationId: getAlbums | ||
produces: | ||
- application/json | ||
parameters: | ||
- name: _artists_ | ||
in: query | ||
type: array | ||
items: | ||
type: string | ||
collectionFormat: csv | ||
default: [] | ||
- name: X-API-VERSION | ||
in: header | ||
type: string | ||
default: v1 | ||
responses: | ||
"200": | ||
description: Ok | ||
schema: | ||
type: array | ||
items: | ||
$ref: "#/definitions/album" | ||
"400": | ||
description: BadRequest | ||
schema: | ||
$ref: "#/definitions/ErrorPayload" | ||
post: | ||
tags: | ||
- albums | ||
operationId: postAlbum | ||
produces: | ||
- application/json | ||
consumes: | ||
- application/json | ||
parameters: | ||
- in: body | ||
name: body | ||
required: true | ||
schema: | ||
$ref: "#/definitions/album" | ||
responses: | ||
"201": | ||
description: Created | ||
schema: | ||
$ref: "#/definitions/album" | ||
"400": | ||
description: BadRequest | ||
schema: | ||
$ref: "#/definitions/ErrorPayload" | ||
/albums/{_id}: | ||
get: | ||
tags: | ||
- albums | ||
operationId: getAlbumById | ||
produces: | ||
- application/json | ||
parameters: | ||
- name: _id | ||
in: path | ||
required: true | ||
type: string | ||
responses: | ||
"200": | ||
description: Ok | ||
schema: | ||
$ref: "#/definitions/album" | ||
"404": | ||
description: NotFound | ||
schema: | ||
$ref: "#/definitions/message" | ||
"400": | ||
description: BadRequest | ||
schema: | ||
$ref: "#/definitions/ErrorPayload" | ||
/albums/{id}/artist: | ||
get: | ||
tags: | ||
- artists | ||
operationId: getArtistByAlbum | ||
produces: | ||
- application/json | ||
parameters: | ||
- name: id | ||
in: path | ||
required: true | ||
type: string | ||
responses: | ||
"200": | ||
description: Ok | ||
schema: | ||
$ref: "#/definitions/album_aRTIST" | ||
"400": | ||
description: BadRequest | ||
schema: | ||
$ref: "#/definitions/ErrorPayload" | ||
definitions: | ||
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 | ||
album: | ||
required: | ||
- _id | ||
- artist | ||
- title | ||
type: object | ||
properties: | ||
_id: | ||
type: string | ||
title: | ||
type: string | ||
artist: | ||
type: string | ||
additionalProperties: false | ||
album_aRTIST: | ||
required: | ||
- albums | ||
- id | ||
- name | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
name: | ||
type: string | ||
albums: | ||
type: array | ||
items: | ||
$ref: "#/definitions/album" | ||
additionalProperties: false | ||
message: | ||
required: | ||
- code | ||
- message | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
code: | ||
type: integer | ||
format: int64 | ||
additionalProperties: false |
190 changes: 190 additions & 0 deletions
190
openapi-cli/src/test/resources/cmd/sanitize/openapi_3.0.0.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,190 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Api V1 | ||
version: 0.0.0 | ||
servers: | ||
- url: "http://{server}:{port}/api/v1" | ||
variables: | ||
server: | ||
default: localhost | ||
port: | ||
default: "8080" | ||
paths: | ||
/albums: | ||
get: | ||
tags: | ||
- albums | ||
operationId: getAlbums | ||
parameters: | ||
- name: _artists_ | ||
in: query | ||
schema: | ||
type: array | ||
items: | ||
type: string | ||
default: [] | ||
- name: X-API-VERSION | ||
in: header | ||
schema: | ||
type: string | ||
default: v1 | ||
responses: | ||
"200": | ||
description: Ok | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/album' | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ErrorPayload' | ||
post: | ||
tags: | ||
- albums | ||
operationId: postAlbum | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/album' | ||
required: true | ||
responses: | ||
"201": | ||
description: Created | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/album' | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ErrorPayload' | ||
/albums/{_id}: | ||
get: | ||
tags: | ||
- albums | ||
operationId: getAlbumById | ||
parameters: | ||
- name: _id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
responses: | ||
"200": | ||
description: Ok | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/album' | ||
"404": | ||
description: NotFound | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/message' | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ErrorPayload' | ||
/albums/{id}/artist: | ||
get: | ||
tags: | ||
- artists | ||
operationId: getArtistByAlbum | ||
parameters: | ||
- name: id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
responses: | ||
"200": | ||
description: Ok | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/album_aRTIST' | ||
"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 | ||
format: date-time | ||
status: | ||
type: integer | ||
format: int64 | ||
reason: | ||
type: string | ||
message: | ||
type: string | ||
path: | ||
type: string | ||
method: | ||
type: string | ||
album: | ||
required: | ||
- _id | ||
- artist | ||
- title | ||
type: object | ||
properties: | ||
_id: | ||
type: string | ||
title: | ||
type: string | ||
artist: | ||
type: string | ||
additionalProperties: false | ||
album_aRTIST: | ||
required: | ||
- albums | ||
- id | ||
- name | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
name: | ||
type: string | ||
albums: | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/album" | ||
additionalProperties: false | ||
message: | ||
required: | ||
- code | ||
- message | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
code: | ||
type: integer | ||
format: int64 | ||
additionalProperties: false |
Oops, something went wrong.