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

oadg

v1.2.2

Published

It is a command-line tool to generate an OpenAPI document as output by reading the provided Swagger/OpenAPI based `.json` or `.yaml` file.

Downloads

2

Readme

openapi-docgen-cli

It is a command-line tool to generate an OpenAPI document as output by reading the provided Swagger/OpenAPI based .json or .yaml file. It can also be used to convert .json to .yaml file or vice-versa.

Prerequisite

You should have these applications installed at your system.

  • node.js
  • npm (usually it comes along with node.js)

Setup

You can install it at your system via npm

npm install oadg --global

or

npm i oadg -g

Usage

The usage can be found in the help content as shown below

% oadg -h                     
oadg ~ OpenAPI DocGen

It is a command-line tool to generate an OpenAPI document as output by reading the provided Swagger/OpenAPI based '.json' or '.yaml' file.

Usages:
  oadg (--help|--version)
  oadg <filepath> (<output>) (--integrated)
  oadg <filepath> (<output>) (--json|--yaml) --isolated
  oadg <filepath> --dev (--host=<hostaddr>) (--port=<portnum>)

Parameters:
  filepath    Input Swagger or OpenAPI filepath
  output      Output file/dir name
  hostaddr    Serving host address for dev server
  portnum     Serving port number for dev server

Options:
  -h --help               Show help
  -v --version            Show version
  -j --json               Target output as JSON file
  -y --yaml               Target output as YAML file
  -s --isolated           Generate isolated files
  -n --integrated         Generate integrated file [default: true]
  -d --dev                Start dev server at <filepath> directory
  -u --host=<hostaddr>    Set host of dev server [default: localhost]
  -p --port=<portnum>     Set host of dev server [default: 8080]

You can use any combination of above listed Usages patterns.

Use-cases

Below are the various use cases of this app. Just find out the one relevant for you.

Generate single-file embedded doc with default name

To generate doc for any sample.json, run this command

oadg sample.json

By default, it would generate a sample.html file with embedded content. Here, the .html name is extracted from the base filename of sample.json, i.e., sample.

Generate single-file embedded doc with custom name

If you specify output name, run this command

oadg sample.json petstore

It would generate a petstore.html file with embedded content. Here, the provided custom filename is used for .html file.

Generate isolated files doc

Similarly, to generate isolated content, run this command

oadg sample.json --isolated

It would generate a wrapper file as sample.html that loads the sample.json file content.

Generate isolated files doc with custom name

If you specify output name, run this command

oadg sample.json petstore --isolated

It would generate a petstore.html file with embedded content. Here, the provided custom filename is used for .html & .json files.

Generate isolated files doc with alternative file type

Here, alternative file type could be generated as

oadg sample.json --isolated --yaml

That would generates the sample.yaml along with wrapper file sample.html which loads the sample.yaml file content.

Similarly, you could generate the sample.json along with wrapper file sample.html via

oadg sample.yaml --isolated --json

Convert file type

You can convert the file type from json to yaml or vice-versa, like this

oadg sample.json --yaml

That would convert sample.json to sample.yaml.

Similarly, you could generate the sample.json via

oadg sample.yaml --json

Just make sure not to use --isolated flag in case of file conversion otherwise it will generate wrapper file as well.

Using in dev-mode for real-time edit & preview

In dev-mode, isolated wrapper .html is generated automatically and served via development server on browser. So that you can edit the .json or .yaml source file and preview it live at serving URL.

oadg sample.json --dev

After beginning the dev server, it would automatically opens the default browser with serving URL. You just need to refresh it everytime after you make any change in the .json or .yaml source file.

Running the dev-server at different host/port

To run the dev server at different host or port, run this command

oadg sample.json --dev --host=localhost --port=8000

Here you can specify the custom host address and/or port number where you want the dev server to seve at.