JKHeadley / JKHeadley/rest-hapi

Custom header option to swagger ui for all routes

Open
#189 1 comment 0 reactions 0 assignees View on GitHub
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:

![Screen Shot 2019-08-15 at 1 39 02 AM](https://user-images.githubusercontent.com/1416832/63050730-90643380-befd-11e9-9e3c-37f8725eb632.png)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.