tonic + npm: swagger-parser

const SwaggerParser = require("swagger-parser") let schema = JSON.parse(` { "swagger": "2.0", "info": { "version": "1.0.0", "title": "petstore" }, "definitions": { "def with spaces": { "type": "string" } }, "paths": { "/test": { "get": { "responses": { "200": { "description": "a paginated collection of products", "schema": { "$ref": "#/definitions/def with spaces" } } } } } } } `) SwaggerParser.bundle(schema, function(err, api) { if (err) { console.error(err); } else { console.log(api.paths["/test"].get.responses["200"].schema.$ref) console.log(Object.keys(api.definitions)) } });
Created from: https://tonicdev.com/npm/swagger-parser
Loading…

no comments

    sign in to comment