Skip to content

Commit

Permalink
Add Authorization header to OpenAPI docs
Browse files Browse the repository at this point in the history
Closes #43

Signed-off-by: flakey5 <[email protected]>
  • Loading branch information
flakey5 committed May 14, 2024
1 parent acf323c commit b599fa0
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,34 @@ const stackable: Stackable<AiWarpConfig> = async function (fastify, opts) {
})
}

await fastify.register(platformaticService, opts)
if (config.service === undefined) {
config.service = {}
}

const currentOpenApiConfig = typeof config.service.openapi === 'object' ? config.service.openapi : {}
config.service.openapi = {
...currentOpenApiConfig,
components: {
...currentOpenApiConfig.components,
securitySchemes: {
...currentOpenApiConfig.components?.securitySchemes,
aiWarpJwtToken: {
type: 'apiKey',
in: 'header',
name: 'Authorization'
}
}
}
}

if (config.auth?.jwt !== undefined) {
await fastify.register(platformaticService, {
...opts,

Check failure on line 47 in index.ts

View workflow job for this annotation

GitHub Actions / Linting

Unexpected trailing comma

Check failure on line 48 in index.ts

View workflow job for this annotation

GitHub Actions / Linting

Trailing spaces not allowed
} as any)
} else {
await fastify.register(platformaticService, opts)
}

await fastify.register(warpPlugin, opts) // needs to be registered here for fastify.ai to be decorated

Expand Down

0 comments on commit b599fa0

Please sign in to comment.