-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for updated multi example support
- Loading branch information
Showing
4 changed files
with
379 additions
and
35 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
test/data/valid_openapi/multiContentTypesMultiExample.json
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,127 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"version": "1.0.0", | ||
"title": "Swagger Petstore", | ||
"license": { | ||
"name": "MIT" | ||
} | ||
}, | ||
"servers": [{ | ||
"url": "http://petstore.swagger.io/v1" | ||
}], | ||
"paths": { | ||
"/pets": { | ||
"post": { | ||
"summary": "List all pets", | ||
"operationId": "pets - updated", | ||
"tags": [ | ||
"pets" | ||
], | ||
"parameters": [{ | ||
"name": "limit1", | ||
"in": "query", | ||
"description": "How many items to return at one time (max 100)", | ||
"schema": { | ||
"type": "integer", | ||
"format": "int32" | ||
} | ||
}], | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Error" | ||
}, | ||
"examples": { | ||
"ok_example": { | ||
"value": { | ||
"message": "ok" | ||
} | ||
}, | ||
"not_ok_example": { | ||
"value": { | ||
"message": "fail" | ||
} | ||
} | ||
} | ||
}, | ||
"application/xml": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Error" | ||
}, | ||
"examples": { | ||
"ok_example": { | ||
"value": { | ||
"message": "ok" | ||
} | ||
}, | ||
"not_ok_example": { | ||
"value": { | ||
"message": "fail" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"default": { | ||
"description": "unexpected error", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Error" | ||
}, | ||
"example": { | ||
"message": "Not Found" | ||
} | ||
}, | ||
"application/xml": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Error" | ||
}, | ||
"example": { | ||
"message": "Not Found" | ||
} | ||
} | ||
} | ||
}, | ||
"200": { | ||
"description": "Ok", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Error" | ||
}, | ||
"example": { | ||
"message": "Found", | ||
"code": 200123 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"Error": { | ||
"required": [ | ||
"code", | ||
"message" | ||
], | ||
"properties": { | ||
"code": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
106 changes: 106 additions & 0 deletions
106
test/data/valid_openapi/multiExampleRequestVariousResponse.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,106 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: None | ||
version: 1.0.0 | ||
description: None | ||
paths: | ||
/v1: | ||
post: | ||
requestBody: | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: "#/components/schemas/World" | ||
examples: | ||
valid-request: | ||
value: | ||
includedFields: | ||
- user | ||
- height | ||
- weight | ||
missing-required-parameter: | ||
value: | ||
includedFields: | ||
- eyeColor | ||
responses: | ||
200: | ||
description: None | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: "#/components/schemas/Request" | ||
examples: | ||
valid-request: | ||
summary: Request with only required params | ||
value: | ||
{ | ||
"user": 1 | ||
} | ||
not-matching-key: | ||
summary: Complete request | ||
value: | ||
{ | ||
"user": 99, | ||
"height": 168, | ||
"weight": 44 | ||
} | ||
400: | ||
description: None | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: "#/components/schemas/Request" | ||
examples: | ||
missing-required-parameter: | ||
summary: Request with only bad params | ||
value: | ||
{ | ||
"eyeColor": "gray" | ||
} | ||
500: | ||
description: None | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: "#/components/schemas/Request" | ||
examples: | ||
not-matching-key-1: | ||
summary: Failed request - Negative user | ||
value: | ||
{ | ||
"user": -99 | ||
} | ||
not-matching-key-2: | ||
summary: Failed request - All negatives | ||
value: | ||
{ | ||
"user": -999, | ||
"height": -168, | ||
"weight": -44 | ||
} | ||
|
||
components: | ||
schemas: | ||
World: | ||
type: object | ||
properties: | ||
includedFields: | ||
type: array | ||
Request: | ||
type: object | ||
required: | ||
- user | ||
- height | ||
- weight | ||
properties: | ||
user: | ||
type: integer | ||
description: None | ||
height: | ||
type: integer | ||
description: None | ||
weight: | ||
type: integer | ||
description: None | ||
eyeColor: | ||
type: string |
Oops, something went wrong.