0

I have Swagger, which works just fine. But I cant find a way to export the routes to JSON. I remember of doing this, just by visiting a URL in the browser, but I can't remember it now.

My swagger is setup like this:

const swaggerOptions = new DocumentBuilder()
    .setTitle('Some API Docs')
    .setDescription('Some API description')
    .setVersion('1.0')
    .build();

  const swaggerDocument = SwaggerModule.createDocument(app, swaggerOptions);
  SwaggerModule.setup('docs', app, swaggerDocument);

And I can access the Swagger UI using: localhost:3000/docs

I have read the official documentation, and they mention to use:

  • http://localhost:3000/api/json or http://localhost:3000/api-json

Also, I looked on SO, and there is this thread

Unfortunately, none of it works in my case.

What is the URL to get the documentation in JSON?

Amiga500
  • 5,874
  • 10
  • 64
  • 117
  • See [How to export a Swagger JSON/YAML file from Swagger UI?](https://stackoverflow.com/q/48525546/113116) – Helen Aug 16 '21 at 12:17

1 Answers1

9

Based on your SwaggerModule configuration the URL for JSON should be at /docs-json.

The official documentation mentions api-json because they register using api as the first param

Jesse Carter
  • 20,062
  • 7
  • 64
  • 101