Operations should inherit consumes and produces from ApiDeclaration object during Swagger 1.0 -> 2.0 conversion #41
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.
Using swagger-parser to convert a 1.X resource listing to a Swagger 2.0 is a great feature, but I discovered this small annoyance.
If this is one of my 1.X resource listings (e.g. /api-docs/v2/employees)
{ "apiVersion": "2.1.2", "swaggerVersion": "1.2", "basePath": "/", "resourcePath": "/v2/employees", "produces": ["application/json"], "consumes": ["application/json"], "apis": [ { "path": "/v2/employees", "operations": [ { "method": "GET", "summary": "Find all employees for company", "notes": "", "type": "Employee", "nickname": "getEmployees", "authorizations": {"privateAuthUser": []}, "parameters": [], "responseMessages": [ { "code": 200, "message": "Ok", "responseModel": "Employee" } ] //end of responseMessages } //end of operation ] //end of operations } //end of api ] //end of apis } //end of ApiDeclarationThe following Swagger 2.0 YAML is produced:
Notice that the consumes and produces defined at the ApiDeclaration level are not inherited by the Swagger 2.0 operation object.
A few things to note: