swagger-api / swagger-api/swagger-codegen
[Java Spring] Response headers not generated from swagger file
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
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.")
}
)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the spring generator entry point and the swagger.json response definition, then reproduce the issue with swagger-codegen-cli.jar using the command in the report and inspect the generated @ApiResponse annotation. Done means response headers from the Swagger response are represented in the generated annotation with their names, types, and descriptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100