Fleek Parser
Parser module that parses swagger documentation json into a single fully dereferenced object. Acts as the linch pin to the Fleekjs environment of micro-utilities.
$ npm install fleek-parser
Beyond basic JSON parse:
- Render all
$ref
within the JSON - Render all
$ref
referring to a separate file - TODO - Merge
allOf
objects - provide various utilities to access the Swagger document in a non-standard way
Key
Usage
Basic
app.js
var parser = ; // parse stringified JSON as json objectvar swaggerFile = fsvar swagger = parser; // OR // parse JSON file from pathvar swagger = parser;
swagger.json
{ "swagger": "2.0", "info": { "version": "2.0.0", "title": "Swagger Petstore", "contact": { "name": "Swagger API Team", "url": "http://swagger.io" } }, "host": "petstore.swagger.io", "basePath": "/api", "schemes": [ "http" ], "paths": { "/pets": { "get": { "tags": [ "Pet Operations" ], "summary": "finds pets in the system", "responses": { "200": { "description": "pet response", "schema": { "type": "array", "items": { "$ref": "#/definitions/Pet" } } } } } } }, "definitions": { "Pet": { "type": "object", "required": [ "id" ], "properties": { "id": { "type": "integer", "format": "int64" } } } }}
Dereference example
console// {// "type": "object",// "required": [// "id"// ],// "properties": {// "id": {// "type": "integer",// "format": "int64"// }// }// }
Utilities
Additional properties are attached to the result to simplify usage
var parser = ;var swagger = parser; console;console;console;
Reference Material
Swagger
By the authors
Authors
Built and maintained with by the Hart team.