-
Notifications
You must be signed in to change notification settings - Fork 209
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
Added simplified request and response body matching in case of multiple examples. #792
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c12e738
Added simplified request and response body matching in case of multip…
VShingala 87cf696
Added comments for req-res matching for multi examples
VShingala 4d94c7e
Added tests for updated multi example support
VShingala eb3cc5e
Use only correct content type request body examples to generate colle…
VShingala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@VShingala What's the reason for doing this? The request and response can be of different types. Why give preference to same content types?
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.
@webholik Yes, we only give preference to same content type if available. Reasoning is, It makes better example if both request and response body are in same content type.
Although, if same content type is not present we do pair different content types as well.