Skip to content

Commit

Permalink
Added tests for updated multi example support
Browse files Browse the repository at this point in the history
  • Loading branch information
VShingala committed May 14, 2024
1 parent 87cf696 commit 4d94c7e
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 35 deletions.
127 changes: 127 additions & 0 deletions test/data/valid_openapi/multiContentTypesMultiExample.json
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"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ paths:
value:
includedFields:
- user
extra-value:
value:
includedFields:
- eyeColor
responses:
200:
description: None
Expand All @@ -44,6 +48,10 @@ paths:
{
"user": 1
}
extra-value-2:
value:
includedFields:
- eyeColor
components:
schemas:
World:
Expand Down
106 changes: 106 additions & 0 deletions test/data/valid_openapi/multiExampleRequestVariousResponse.yaml
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
Loading

0 comments on commit 4d94c7e

Please sign in to comment.