Parsing swagger-spec copies responses.200.schema into property responses.200.responseSchema?
See original GitHub issueHere is an example of an endpoint with the schema property being copied.
"post": {
"tags": [
"users"
],
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/xml",
"application/json"
],
"parameters": [
{
"name": "userId",
"in": "path",
"description": "the ID of the user",
"required": true,
"type": "string"
},
{
"name": "AuthToken",
"in": "header",
"description": "Authentication token",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "Successful operation",
"schema": {
"$ref": "#/definitions/GameUsage"
}
},
"400": {
"description": "Invalid status value"
}
}
}
}
is transformed into
"/users" : {
"post" : {
"tags" : [ "users" ],
"consumes" : [ "application/x-www-form-urlencoded" ],
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "userId",
"in" : "path",
"description" : "the ID of the user",
"required" : true,
"type" : "string"
},
{
"name" : "AuthToken",
"in" : "header",
"description" : "Authentication token",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "Successful operation",
"responseSchema" : {
"$ref" : "#/definitions/GameUsage"
},
"schema" : {
"$ref" : "#/definitions/GameUsage"
}
},
"400" : {
"description" : "Invalid status value"
}
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Describing Responses - Swagger
Under responses , each response definition starts with a status code, such as 200 or 404. An operation typically returns one successful status...
Read more >Swagger: Specify Two Responses with the Same ... - Baeldung
In this article, we'll write an API specification that allows returning two different objects for the same response code.
Read more >Error returning boolean in Swagger-Node - Stack Overflow
This is my swagger spec. responses: '200': description: a string that represents a boolean value schema: type: string.
Read more >Swagger2 — metosin/spec-tools 0.10.5 - cljdoc
An utility to transform Specs to Swagger2 Schemas. Spec transformations. swagger/transform converts specs into Swagger2 Schema. Transformation can be customized ...
Read more >Create Your First OpenAPI Definition with Swagger Editor
OpenAPI definitions can be serialized in either YAML or JSON and ... default: json responses: '200': description: Success response schema: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You have two options:
either use the configured mapper provided by
swagger-core
viaio.swagger.v3.core.util.Json.mapper()
(orYaml.mapper()
) and if needed customize it further e.g withSerializationFeature.INDENT_OUTPUT
add the following to your mapper config:
mapper.addMixIn(Response.class, ResponseSchemaMixin.class);
Glad to see your issue is solved. About the ResponseSchemaMixin, it establishes the
responseSchema
attribute as theschema
property. This is part of a change made in core to supportModel
in the schema attribute which was previously aproperty
. https://github.com/swagger-api/swagger-core/blob/1.5/modules/swagger-core/src/main/java/io/swagger/jackson/mixin/ResponseSchemaMixin.java