tspec
tspec copied to clipboard
Authentication config won't work
Despite defining the security scheme for JWT in my Tspec configuration, the output in the JSON file doesn't reflect this correctly
Tspec Configuration
const tspecParams: Tspec.GenerateParams = {
specPathGlobs: ["./src/**/*"],
// tsconfigPath: "./tsconfig.json",
outputPath: "./src/config/openapi.json",
openapi: {
title: "Tspec API",
version: "0.0.1",
securityDefinitions: {
jwt: {
type: "http",
scheme: "bearer",
bearerFormat: "JWT",
},
},
},
debug: true,
ignoreErrors: true,
};
const openApiSpec = await generateTspec(tspecParams);
API Specification:
export type CommentApiSpec = Tspec.DefineApiSpec<{
security: "jwt";
paths: {
"/comment/:postId": {
get: {
summary: "Get comment by post id";
path: { postId: Tspec.UuidString };
responses: { 200: CommentType[] };
};
};
}>;
Resulting JSON Output (part of):
"info": {
"title": "Tspec API",
"version": "0.0.1"
},
"openapi": "3.0.3",
"paths": {
"/comment/:postId": {
"get": {
"operationId": "CommentApiSpec_get_/comment/:postId",
"tags": [],
"summary": "Get comment by post id",
"security": [
{
"jwt": []
}
],
},
},
},
I checked that this code generates output correctly
But I can't find any Authorization button at all in swagger ui page