Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option sto disable json and yaml API definition serving #3157

Open
1 task done
wiliamsouza opened this issue Nov 7, 2024 · 1 comment
Open
1 task done

Add option sto disable json and yaml API definition serving #3157

wiliamsouza opened this issue Nov 7, 2024 · 1 comment
Labels

Comments

@wiliamsouza
Copy link

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

There is no way to disable json and yaml API definition endpoints.

Describe the solution you'd like

An option like exist for enable or disable swagger UI.

Teachability, documentation, adoption, migration strategy

Some times you do not want to make your API public available for any reason.

What is the motivation / use case for changing the behavior?

I need to create a work around to disable those endpoint:

  const enable = false;

  SwaggerModule.setup("api", app, swaggerDocument(app), {
    swaggerUiEnabled: enable,
    patchDocumentOnRequest: (_req, _res, document) => {
      if (enable) {
        return document;
      }
      return {
        openapi: "3.0.0",
        info: {
          title: "You shall not pass! Just kidding, not found ;D",
          version: "1.0",
        },
        paths: {},
      };
    }
  });
@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants