-
-
Notifications
You must be signed in to change notification settings - Fork 553
Closed
Labels
invalidThis doesn't seem rightThis doesn't seem right
Description
How to add example in an API response without losing the Schema?
This case is based on Java Map object for Json representation.
i.e. if I use the following
@ApiResponse(responseCode = "200", description = "OK")
I get the following correct response
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object"
}
}
}
}
}
But if I modify the @apiresponse to add an example using the following
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(examples = {@ExampleObject(value = "{\"Key\": \"Value\"}")})
)
Then the response object is now incorrect.
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"example": {
"Key": "Value"
}
}
}
}
}
The Schema gets removed.
So - how would I add a example to the existing @apiresponse without losing the schema? Is this a bug?
I have created a unit test in the following branch for app51.
https://github.com/ianwallen/springdoc-openapi/tree/how_to_add_example_response_json
It produced the following error.
java.lang.AssertionError: paths./test5.post.responses.200.content.application/json
Expected: schema
but none found
Thank you
Metadata
Metadata
Assignees
Labels
invalidThis doesn't seem rightThis doesn't seem right