[Java Spring] Response headers not generated from swagger file
Description
When generating a new API interface, the response headers declared in the swagger file is not included in the @ApiResponse annotation, they are simply ignored
Swagger-codegen version
2.4.0
Swagger declaration file content or url
"201DomesticPaymentConsentsCreated": {
"description": "Domestic Payment Consents Created",
"headers": {
"x-fapi-interaction-id": {
"type": "string",
"description": "An RFC4122 UID used as a correlation id."
},
"x-jws-signature": {
"type": "string",
"description": "Header containing a detached JWS signature of the body of the payload."
}
},
"schema": {
"$ref": "#/definitions/OBWriteDomesticConsentResponse1"
}
}
Generated annotation missing the headers
@ApiResponse(
code = 201,
message = "Domestic Payment Consents Created",
response = OBWriteDomesticConsentResponse1.class
)
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i swagger.json -l spring --additional-properties interfaceOnly=true,dateLibrary=java8,serializableModel=true,java8=true
Steps to reproduce
-
Retrieve swagger file from openbanking uk repo https://github.com/OpenBankingUK/read-write-api-specs/blob/v3.0.0/dist/payment-initiation-swagger.json
-
Generate using command line above
Related issues/PRs
Suggest a fix/enhancement
How the @ApiResponse annotation should look like
@ApiResponse(
code = 201,
message = "Domestic Payment Consents Created",
response = OBWriteDomesticConsentResponse1.class,
responseHeaders = {
@ResponseHeader(name = "x-fapi-interaction-id", response = String.class, description = "An RFC4122 UID used as a correlation id."),
@ResponseHeader(name = "x-jws-signature", response = String.class, description = "Header containing a detached JWS signature of the body of the payload.")
}
)
Is there any update on this old bug? Just ran into the same issue in version 7.2.0