Swagger is used with typescript with swagger-jsdocs and swagger-ui-express. It works perfectly fine on local and shows all the specs but when deployed it doesn't show any specs.
const options = {
definition: {
openapi: "3.1.0",
info: {
title: "SFMB Documentation",
version: "0.1.0",
description:
"SFMB API Documentation",
},
components: {
securitySchemes: {
bearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT',
}
}
},
security: [{
bearerAuth: []
}],
servers: [
{
url: "http://localhost:8080",
description: "Local Server for version 1"
},
],
},
apis: ["**/*.ts"]
};
const swaggerSpecs = swaggerJsdoc(options);
This is the swagger specs file
The actual swagger code are written in files
/**
* @swagger
* /api/v1/location/locationParent:
* put:
* tags:
* - Location
* summary: Update location Parent
* description: Update location Parent
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.0",
These are the versions I am using.
This route is added for displaying the docs
app.use('/docs', swagger.serve, swagger.setup(swaggerSpecs));
Is it regarding the comments getting ignored when we transpile typescript code?
I faced a similar error message. By setting "removeComments": false in your tsconfig.json should do the trick. Also when deploying, I had to pass in to the "apis" field, .js files as it gets compiled to javascript files after deployment.