restapi-docs
v1.0.5
Published
This package generate openapi specifications and render using a provider like swagger, scaler, and more.
Downloads
181
Maintainers
Readme
RestAPI-Docs
RestAPI-Docs is an npm package that allows you to render OpenAPI specifications using different tools such as Swagger UI, Redoc, RapiDoc, StoplightIO, and Scalar. It can either take an OpenAPI specification URL, file, or generate the specification directly from database model schemas (like Parse Server's /schemas
endpoint).
Features
- Multiple Renderers: Support for Swagger, Redoc, RapiDoc, StoplightIO, and Scalar renderers.
- Flexible Input Options: Render OpenAPI specs from a URL, local spec file, or generate from Parse Server schemas.
- CLI Tool: Can be used as a command-line tool or a programmatic package.
- Easy Integration: Works seamlessly with Parse Server schemas.
Installation
You can install the package using npm:
npm install restapi-docs
Usage
CLI Usage
You can use the CLI to render OpenAPI specs from various sources:
- Render from a URL:
restapi-docs openapi --specUrl <openapi-spec-url> --renderer <renderer>
Example:
restapi-docs openapi --specUrl https://api.example.com/openapi.json --renderer swagger
- Render from a local spec file:
restapi-docs openapi --specFile <openapi-spec-file> --renderer <renderer>
Example:
restapi-docs openapi --specFile ./openapi.json --renderer scalar
Build OpenAPI Document from Parse Server Schemas:
Creates OpenAPI Specification from Parse-Server schemas.
- Render from parse-server schemas:
restapi-docs parse-server --appId <parse-server-app-id> --masterKey <parse-server-master-key> --serverUrl <parse-server-server-url> --renderer <renderer>
Example:
restapi-docs parse-server --appId parse-server-app-id --masterKey parse-server-master-key --serverUrl https://example.com/parse --renderer scalar
Programmatic Usage
You can also use the package programmatically in your Node.js application:
Available Renderers
swagger
– Swagger UIredoc
– Redocrapidoc
– RapiDocstoplightio
– StoplightIOscalar
– Scalar
Commands & Options
The following commands with options are available for both the CLI and programmatic usage:
parse-server
--appId
orappId
: Parse-Server Application-ID--masterKey
ormasterKey
: parse-Server Master-Key--serverUrl
orserverUrl
: URL to the Parse Server
- Example
restapi-docs parse-server --<options>
openapi
--specUrl
orspecUrl
: URL to the OpenAPI specification.--specFile
orspecFile
: Path to the local OpenAPI specification file.
- Example
restapi-docs openapi --<options>
Global Options
The following options can be used in-conjuction with all commands.
--title
ortitle
: A title for specification. It is shown as browser title--desc
ordesc
: A description of the specification.--summary
orsummary
: A summary of the specification.--port
orport
: The port at which the app will listen in stand-alone mode.--path
orpath
: A path after hostname. The default value /_docs--renderer
or-r
orprovider
: Specifies the renderer engine.- swagger
- redoc
- stoplightio
- scalar
- rapidoc