Giter Site home page Giter Site logo

expand-swagger-refs's Introduction

expand-swagger-refs Build Status Build status

Automatically expand $ref values in your Swagger schema:

  • From a function
  • From a file
  • From stdin
  • Zero dependencies

Install

npm install expand-swagger-refs

NOTE: If you want to use the file or stdin options, you may want to install globally with -g

Module functions

Importing the module provides 2 methods for expansion, with or without mutation:

const { expand, expanded } = require('expand-swagger-refs');
const schema = require('./api/swagger.json');

// Create a copy of the schema, with $ref values expanded: 
const expandedSchema = expanded(schema);

// Or expand the schema object in-place (mutates the object):
expand(schema)

stdin > stdout

With the module installed globally, the swagger-expand command is available and will accept valid JSON to stdin:

swagger-expand < swagger.json

The expanded result is written to stdout:

swagger-expand < swagger.json > expanded.json

File input

The swagger-expand command also accepts a filepath as an input:

swagger-expand ~/lol/swagger.json

By default the expanded result will be written adjacent to the input file with -expanded added to the basename. Eg, the input above would write the result to ~/lol/swagger-expanded.json. Absolute and relative paths are supported.

You can tell swagger-expand to overwrite the input file with the expanded result using the -o option:

swagger-expand ~/rofl/swagger.json -o

expand-swagger-refs's People

Contributors

duncanhall avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.