This has been slightly improved in OpenAPI 3.0 - now you can define common headers in the global components/headers section and then $ref these definitions instead of repeating the built-in definitions. You can also $ref entire answers (e.g. 400) to slightly reduce code duplication. However, there is still no way to set common headers for all paths - you need to explicitly specify headers in each answer.
openapi: 3.0.1 ... paths: /: get: responses: '200': description: OK headers: X-RateLimit-Limit: $ref: '#/components/headers/X-RateLimit-Limit' X-RateLimit-Remaining: $ref: '#/components/headers/X-RateLimit-Remaining' /something: get: responses: '200': description: OK headers: X-RateLimit-Limit: $ref: '#/components/headers/X-RateLimit-Limit' X-RateLimit-Remaining: $ref: '#/components/headers/X-RateLimit-Remaining' components: headers: X-RateLimit-Limit: description: Request limit per hour schema: type: integer example: 100 X-RateLimit-Remaining: schema: type: integer example: 96
Helen source share