This package has been deprecated

Author message:

OASGraph CLI has been renamed. Use OpenAPI-to-GraphQL CLI from now on.

oasgraph-cli

0.4.3 • Public • Published

Travis (.org) npm Join the chat at https://gitter.im/oasgraph/Lobby

Please note: OASGraph CLI has been renamed to OpenAPI-to-GraphQL CLI.

OASGraph CLI

Command line interface (CLI) for turning APIs described by OpenAPI Specification (OAS) into GraphQL interfaces.

Overview of translation

Note: To use OASGraph as a library, refer to the oasgraph package.

Installation

npm i -g oasgraph-cli

Usage

Usage: oasgraph <OAS JSON file path or remote url> [options]

Options:
  -V, --version               output the version number
  -p, --port <port>           select the port where the server will start
  -u, --url <url>             select the base url which paths will be built on
  -s, --strict                throw an error if OASGraph cannot run without compensating for errors or missing data in the OAS
  -a, --addSubOperations      nest operations based on path hierarchy
  -f, --fillEmptyResponses    create placeholder schemas for operations with HTTP status code 204 (no response) rather than ignore them
  -o, --operationIdFieldNames  create field names based on the operationId
  --cors                      enable Cross-origin resource sharing (CORS)
  --no-viewer                 do not create GraphQL viewer objects for passing authentication credentials
  --save <file path>          save schema to path and do not start server
  -h, --help                  output usage information

The basic usage of the CLI takes the specified OAS, creates a GraphQL interface for it, and starts a server to host the GraphQL interface.

oasgraph oas.json

You can specify the OAS by pointing to either a local file or a remote url such as http://127.0.0.1:3000/openapi.json. Additionally, you can specify a port number so you can have multiple GraphQL servers running on the same machine.

oasgraph http://127.0.0.1:3000/openapi.json -p 3001

OASgraph can also save a GraphQL schema to a local file, which you can use to inspect or change its content. Please note that the following command will not start the GraphQL server.

oasgraph oas.json --save schema.graphql

To learn more about the other options, please refer here.

Please note that the CLI tool is mainly used for quick testing and does not offer all the features that createGraphQlSchema(oas, options) does.

License

MIT

Package Sidebar

Install

npm i oasgraph-cli

Weekly Downloads

9

Version

0.4.3

License

MIT

Unpacked Size

20.4 kB

Total Files

7

Last publish

Collaborators

  • alan-cha