Closed
Description
Describe the bug
Multiple @ApiResponse annotations inside an @ApiResponses annotation do not keep their order when the openapi spec / "responses" field is generated.
To Reproduce
Steps to reproduce the behavior:
@ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "OK."),
@ApiResponse(
responseCode = "401",
description = "Unauthorized access.")
})
leads to
"responses": {
"401": {
"description": "Unauthorized access."
},
"200": {
"description": "OK."
}
}
Expected behavior
"responses": {
"200": {
"description": "OK."
},
"401": {
"description": "Unauthorized access."
}
}
Additional context
I'm pretty sure the reason is that at https://github.com/springdoc/springdoc-openapi/blob/main/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericResponseService.java#L486 the streams are collected with .collect(Collectors.toSet()) - collecting into a LinkedHashSet instead should lead to a stable ordering.
Metadata
Metadata
Assignees
Labels
No labels