JKHeadley / JKHeadley/rest-hapi
Custom header option to swagger ui for all routes
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 155
- PR merge metrics
- No merged PRs in 30d
Description
According to documentation it's possible to pass a header parameter to a specific route by passing a validate function to route config object like this:
```javascript
server.route({
method: 'PUT',
path: '/generate',
config: {
validate: {
headers: Joi.object({
my_custom_header: Joi.string().required()
}).options({
allowUnknown: true
})
}
}
});
```
But this would add a header option to swagger ui only for the route "/generate" like this image:

I want to to add a common header option to all routes in swagger ui in my hapi server. Is it possible? Please note that I have already used the securityDefinitions to set a api_key. What I want is another common header values to swagger ui.
Contributor guide
Research direction
Start by reviewing the route config's validate.headers behavior and the existing securityDefinitions configuration used by Swagger UI. Trace how these settings are translated into the Swagger UI for individual routes. Done means Swagger UI exposes the requested additional header for all routes without removing the existing API key option.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api, documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100