New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

swagger-inline2

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-inline2

Generate your swagger files from inline swagger comments.

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

swagger-inline

Node module for extracting swagger endpoints from inline comments.

Install

npm install --save-dev swagger-inline

Build

npm run build # single build
npm start # build + watch

Test

npm test # single run
npm run test-watch # test + watch

Usage

Javascript

swaggerInline([inputGlobs...], options) => Promise => json | yaml

const swaggerInline = require('swagger-inline');

swaggerInline(['src/**/*.js', 'test/**/*.js'], {
    base: 'swaggerBase.json',
}).then((generatedSwagger) => {
    /* ... */
});

Cli

swagger-inline <inputGlobs ...> [--base] [--format]

swagger-inline 'src/**/*.js' --base 'swaggerBase.json' # outputs built swagger.json

Options:

  • inputGlobs: Files/globs to search for swagger comments.
  • base: Base swagger.json or swagger.yml to build onto
  • format: Output filename - .json or .yaml (default: .json)
  • 'logger': Function called for logging.

Example:

1) Create a project

swaggerBase.yml

swagger: "2.0"
host: "petstore.swagger.io"
basePath: "/api"
schemes: ['http']

api.js


/*
 * @api [get] /pets
 * description: "Returns all pets from the system that the user has access to"
 * responses:
 *   "200":
 *     description: "A list of pets."
 *     schema:
 *       type: "String"
 */

api.route('/pets', function() {
    /* Pet code 😺 */
});
2) Run Command
swagger-inline './*.js' --base './swaggerBase.yml'

Output:

swagger.yml

swagger: "2.0"
host: "petstore.swagger.io"
basePath: "/api"
schemes: ['http']
/pets:
  get:
    description: Returns all pets from the system that the user has access to
    responses:
      '200':
        description: A list of pets.
        schema:
          type: "String"

Keywords

FAQs

Package last updated on 17 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc