Security not applying to the securitySchemes or schema
jcodog opened this issue · 1 comments
jcodog commented
I have added an api key to my router so that when you go to docs a new authorise button appears, however when you try to make a request, it does not apply the API key you specify into the headers as expected, how do I fix this? I want to be able to have the docs show the same security etc as the main API.
export const router = OpenAPIRouter({
docs_url: "/",
schema: {
info: {
title: "JCoNet LTD API",
version: "1",
},
},
});
router.registry.registerComponent("securitySchemes", "api_key", {
type: "apiKey",
in: "header",
name: "x-api-key",
});
As you can see in the code the scheme is shown but is not being included in the docs examples so isn't applying the header, have I done something wrong or does the docs not display the headers you provide in authorise?
jcodog commented
Is this the correct way, this is what I have tried most recently.
code:
export const router = OpenAPIRouter({
docs_url: "/",
schema: {
info: {
title: "JCoNet LTD API",
version: "1",
},
security: {
api_key: [
{
type: "apiKey",
in: "header",
name: "x-api-key",
},
],
},
},
});
router.registry.registerComponent("securitySchemes", "api_key", {
type: "apiKey",
in: "header",
name: "x-api-key",
});
console.log(router.schema);
console:
⎔ Reloading local server...
{
openapi: '3.1.0',
info: { title: 'JCoNet LTD API', version: '1' },
security: { api_key: [ [Object] ] },
components: {
securitySchemes: { api_key: [Object] },
schemas: {},
parameters: {}
},
paths: {},
webhooks: {}
}