-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set additional route options from auth plugin added in route options auth #4520
Labels
support
Questions, discussions, and general support
Comments
@szmyt151 I think you want to play around with This is from my own code-base, so it will be missing context. The point is: you can use rules to configure universal route options. The processor parses your declare module '@hapi/hapi' {
interface RouteRules {
consumes?: SwaggerRouteRules['consumes'];
deprecated?: SwaggerRouteRules['deprecated'];
order?: SwaggerRouteRules['order'];
payloadType?: SwaggerRouteRules['payloadType'];
produces?: SwaggerRouteRules['produces'];
responses?: SwaggerRouteRules['responses'];
}
}
export const swaggerRulesProcess = {
processor(rules: RouteRules) {
const isSwaggerConfig = Boolean(
rules.consumes ||
rules.deprecated ||
rules.order ||
rules.payloadType ||
rules.produces ||
rules.responses
)
const config: SwaggerRouteRules = {};
if (isSwaggerConfig) {
config.consumes = rules.consumes;
config.deprecated = rules.deprecated;
config.order = rules.order;
config.payloadType = rules.payloadType;
config.produces = rules.produces;
config.responses = rules.responses;
return {
tags: ['api'],
plugins: {
'hapi-swagger': config
}
};
}
return null;
},
schema: {
consumes: Joi.array().items(Joi.string()),
deprecated: Joi.boolean(),
order: Joi.number(),
payloadType: Joi.string(),
produces: Joi.array().items(Joi.string()),
responses: Joi.object().pattern(
Joi.string().allow(Joi.number().required()),
Joi.object({
description: Joi.string().required(),
schema: Joi.object().required().allow(null)
})
)
}
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Runtime
nodejs
Runtime version
20
Module version
21.3.10
Used with
hapi
Any other relevant information
No response
How can we help?
I need to change route options from auth plugin:
example route
In auth.setAuth I have options based on it and some manipulations to hide sensitive values I have to put in
Is it possible? I tried in auth plugin
but i can not get information about route in normal way and these values are not passing when I call for /openapi.json route
How to modify route options.plugins via auth plugin?
The text was updated successfully, but these errors were encountered: