Search code examples
swaggernestjsnestjs-swagger

How to customize the path to generate and download a Swagger JSON file nestjs


I have to change the path of the swagger json file, in nestjs documentation it is http://localhost:3000/api-json but for the standard have to keep it

http://localhost:3000/api/openapi.json

Let me know if there is any possible solution for it.


Solution

  • since v6.2 of @nestjs/swagger you can change that value using the jsonDocumentUrl/yamlDocumentUrl option like so:

    SwaggerModule.setup('api', app, document, {
      jsonDocumentUrl: 'openapi.json'
    });