Git Product home page Git Product logo

api-spec-helper's Introduction

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

api-spec-helper's People

Contributors

sandbardev avatar

Stargazers

João Vítor  avatar Thalles Rodrigues avatar  avatar Ruan Ferreira avatar Ademario Santana avatar

Watchers

 avatar

Forkers

gprpaes

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.