swagger-api / swagger-api/swagger.io-docs
Documentation Issue - Reusable Common Response Headers via "Components"
Nobody has claimed this yet.
- Dominant language
- Astro
- Stars
- 1.6k
- Forks
- 407
- Avg merge
- 2m
- Merged PRs (30d)
- 2
Description
The Issue
The describing responses section of the specification documentation states:
Note that, currently, OpenAPI Specification does not permit to define common response headers for different response codes or different API operations. You need to define the headers for each response individually.
Screenshot
Why is this an issue?
Through the use of "headers" via the "components" feature according to the components section of the specification documentation, the previous statement is proven to be inaccurate.
Screenshot

Further Proof
I have also tested this with a modified version of the "Swagger Petstore" sample in the online Swagger Editor. You can test the file below in the editor to see it for yourself. Look out for the Demo-Header response header in the 200 and 400 responses. I have defined a common header under the components section and referenced it using the $ref feature.
Modified Sample - Working Example
API Sample - YAML-Formatted TXT File - Paste the contents of this txt file into the Swagger Editor
Suggested Solution
Assuming that this is intended behavior--I would certainly hope that it is--I would suggest modifying the specification documentation for describing responses to reflect that this behavior is, in fact, possible and supported.
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
Open the linked describing responses documentation page and compare its common-response-headers note with the components page and supplied Petstore example. Update the inaccurate statement to explain reusable headers via components and $ref, then verify the example and surrounding wording remain consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100
