question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export a Swagger JSON/YAML file

See original GitHub issue

I’m submitting a…


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Do we have an ability to export a Swagger JSON/YAML file from Swagger UI? Question from Statckoverflow

Expected behavior

Minimal reproduction of the problem with instructions

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

It could be better if I can export a Swagger JSON/YAML file and send it to someone rather than hosting the doc on the server.

Environment


Nest version: 5.3.11

 
For Tooling issues:
- Node version: 8.4.0  
- Platform: Windows 

Others:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

57reactions
kamilmysliwieccommented, Nov 6, 2018

If your Swagger doc is available behind, let’s say, https://localhost:3000/api simply use https://localhost:3000/api-json to get JSON object.

15reactions
webhackingcommented, Sep 15, 2019

Write it to the file system like this:

const app = await NestFactory.create(ApplicationModule);
const options = new DocumentBuilder()
    .setTitle("Title")
    .setDescription("description")
    .setVersion("1.0")
    .build();
const document = SwaggerModule.createDocument(app, options);

fs.writeFileSync("./swagger-spec.json", JSON.stringify(document));
SwaggerModule.setup("/api", app, document);
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to export swagger.json (or yaml) - Stack Overflow
If you do have the swagger json file which you feed to the swagger UI, then to generate .yaml file just click on...
Read more >
Generating a Swagger JSON File
The Swagger.json file is generated and displayed in a new tab of the browser. Click the Raw Data tab, and then click Save...
Read more >
How to Export Swagger.Json without tools | TheCodeBuzz
Approach to download swagger.json or YAML using Swagger UI or Inspect feature within the browser. ... How to Export Swagger Json file 1....
Read more >
How To Generate A Yaml File From A Swagger Ui
In the editor, navigate to the API. If the API comes with multiple versions, choose the version that is best suited to your...
Read more >
How to export an API document from Swagger - Quora
You can use the "Export" button in the top right corner of the Swagger UI. This will give you the option to download...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found