Node.js Swagger generates UI doc JSON feed

I use Node.js and Swagger to create untrusted APIs. The Swagger interface (demo link here http://petstore.swagger.io/ ) requires JSON submission.

How do you create this channel based on the yagl spec Swagger file? Is there an npm module that can iterate over the yaml file and generate a JSON channel? I'm new to Swagger, so I might have missed something.

+4
source share
2 answers

Swagger user interface must support YAML. You can convert YAML to JSON using the JSYAML library .

+4
source

You can also use the Swagger editor:

http://editor.swagger.io/#/

, , YAML YAML JSON.

.

EDIT:

, swagger ui, :

var swaggerUi = new SwaggerUi({
  url:"http://petstore.swagger.io/v2/swagger.json",
  dom_id:"swagger-ui-container"
});

swaggerUi.load();

:

https://github.com/swagger-api/swagger-ui

, .

(YAML JSON), . express nodejs, :

http://expressjs.com/starter/static-files.html

app.use('/static', express.static('public'));

, , swagger.json , :

http://<yoursite>/swagger.json

, URL- . URL- "url" , swagger-ui, . Swagger-ui , json yaml .

+3

Source: https://habr.com/ru/post/1599771/


All Articles