Swagger "No operations defined in spec!" when deploy on server (Nodejs)

Viewed 4699

In local, Swagger works perfectly well. However, when I deploy the production version on my remote machine, Swagger still shows up on my url / api-docs but throws the error "No operations defined in spec!" and no longer displays the routes, only the Schemas. I cannot identify the source of the error.

In local

On the server

And I have this in Swagger configuration:

const swaggerOptions = {
    swaggerDefinition: {
        openapi: "3.0.0",
        info: {
            version: "1.0.0",
            title: "Kourier API",
            description: "Kourier API Documentation",
            contact: {
                name: "Amazing Developer"
            },
        },
        servers: [
            {url: "http://localhost:3000/"}
        ],
    },
    apis: [
        "./Api/Models/Swagger/User.js",
        "./Api/Models/Swagger/ResetPassword.js",
        "./Api/routes/user/index.js",
        "./Api/routes/reset-password/index.js",
        "./Api/routes/template/index.js",
        "./Api/Models/Swagger/Template.js",
        "./Api/Models/Swagger/Preview.js"
    ]
};
1 Answers

Set your server address to the parameter swaggerDefinition.server.url instead of using http://localhost:3000/

Related