npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

api-spec-helper

v0.1.4

Published

CLI tool to autogenerate swagger documents

Downloads

14

Readme

api-spec-helper

api-spec-helper is a CLI tool meant to help you generate API documentation based on the OAS3.
It generates simple stubs for user-specified paths, allowing you to add methods and responses to your requests automatically. You will still need to customize requestBody properties, request parameters and response schemas. You will also need to fix the indentation in some parts, unfortunately. It is currently in the early stages of development, and only supports JSON formatting.

Installation

Install globally on your computer:

  npm install -g api-spec-helper

Usage

Run api-spec-helper --help to get a list of commands and arguments.

api-spec-helper command references:
  -h      --help                        Display this help message.
  
  -a      --add-path                    Adds routes to specific paths. Expects arguments:
  -p        --paths=users,estates         Specify which paths will be documented.
  -t        --tag='Admin Panel'           Specify a single tag to the generated paths.
  -m        --methods=GET,PUT,DELETE      Specify which methods will be generated. Defaults to all 4.
  -r        --responses=200,203           Specify HTTP status codes for responses. Defaults to 200, 204, 401 & 404.
  
  -g       --generate-stub               Generate barebones OAS3 file. Accepts the following arguments:
  -t         --tag='Admin,Customer'      Specify your project's tags, which will be referenced in your paths. Comma-separated.
  -n         --name='Application'        Specify your application's title.

Examples

generate-stub

  api-spec-helper -g -t 'Admin Panel'

will be equivalent to

  api-spec-helper --generate-stub --tag 'Admin Panel'

and will generate the following json in stdout:

{
    "openapi": "3.0.0",
    "info": {
      "version": "0.1.0",
      "title": "Application Title",
      "description": "Application Description"
    },
    "servers": [
      {
        "url": "http://localhost",
        "description": "Your local application server"
      }
    ],
    "tags": [
       {"name": "Admin Panel", "description": "Tag description"}
    ],
    "paths": {
  

add-path

  api-spec-helper -a -p users,estates -t 'Admin Panel' -m GET,POST -r 200

will be equivalent to

  api-spec-helper --add-path --paths=users,estates --tag='Admin Panel' --methods=GET,POST --responses=200

and will generate the following json in stdout:

"/users": {
 "get": {
      "tags": ["Admin Panel"],
      "summary": "",
      "responses": {
        "200": {"description": "OK"}
      }
    },
  "post": {
      "tags": ["Admin Panel"],
      "summary": "",
      "requestBody": {
        "description": "",
        "content": {

        }
      },
      "responses": {
        "200": {"description": "OK"}
      }
    }
},
"/estates": {
 "get": {
      "tags": ["Admin Panel"],
      "summary": "",
      "responses": {
        "200": {"description": "OK"}
      }
    },
  "post": {
      "tags": ["Admin Panel"],
      "summary": "",
      "requestBody": {
        "description": "",
        "content": {

        }
      },
      "responses": {
        "200": {"description": "OK"}
      }
    }
},

You can choose to send your output for a specific text file or simply copy-paste the stubs on your swagger.json file. Then, adapt and add content as necessary.

Contributing

Please visit the Contributing Guide.

License

MIT