Reputation: 301
I am trying to use swagger-config.yaml to configure swagger UI as mentioned in the document.
The document mentions parameters like requestInterceptor or responseInterceptor, but they are all defined as a function. I don't think I can really put a function in yaml file per specification, and I have tried to put function in it as string but swagger ui won't pick it up.
My question is can I use requestInterceptor or responseInterceptor in the swagger-config.yaml file or these parameters cannot be used in config file? Thanks.
Upvotes: 1
Views: 1028
Reputation: 97540
You are right that the requestInerceptor
and responseInterceptor
cannot be defined in the swagger-config.yaml
file. They can only be defined in JavaScript:
const ui = SwaggerUIBundle({
"dom_id": "#swagger-ui",
deepLinking: true,
...
requestInterceptor: function(req) {
req.headers["MyCustomHeader"] = "value";
return req;
}
})
Upvotes: 1