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

fix(): make swaggerUrl option work #1924

Closed
wants to merge 1 commit into from

Conversation

omermecitoglu
Copy link

@omermecitoglu omermecitoglu commented May 11, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently it serves the swagger.json at /api-json path. But if you prefer to use root (/) as base path instead of api, your json url will become http://localhost:3000/-json

What is the new behavior?

With this change, swaggerUrl option lets developer to decide where to serve swagger.json

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@@ -78,7 +78,8 @@ export class SwaggerModule {
app.use(path, swaggerUi.serveFiles(document, options));

httpAdapter.get(path, (req, res) => res.send(swaggerHtml));
httpAdapter.get(path + '-json', (req, res) => res.json(document));
const swaggerUrl = options?.swaggerUrl ?? (path + '-json');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had this same issue earlier today, and I just manually tested this out. Works like charm!!

@Tony133
Copy link
Contributor

Tony133 commented Nov 15, 2023

Hi @omermecitoglu, as soon as you find some time you can resolve conflicts in this PR ?

@omermecitoglu
Copy link
Author

I think this issue has already been solved by #2273

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

Successfully merging this pull request may close these issues.

None yet

5 participants