Giter VIP home page Giter VIP logo

oas's Introduction

oas

Working with Swagger and OpenAPI definitions is hard. This makes it easier.

Build

Installation

npm install oas

CLI

The CLI tool makes creating API definition files easier. It currently supports Swagger 2 and OpenAPI 3.x documents.

Usage

Go to a directory with your API, and type:

oas init

It will walk you through how to document your API with a OpenAPI 3.0 Spec.

Swagger Inline

oas uses swagger-inline which allows you include a little OpenAPI snippet in a comment above your code, and collects them all together into one OpenAPI file:

/*
 * @oas [get] /pet/{petId}
 * description: "Returns all pets from the system that the user has access to"
 * parameters:
 *   - (path) petId=hi* {String} The pet ID
 *   - (query) limit {Integer:int32} The number of resources to return
*/
route.get("/pet/:petId", pet.show);

You need to start with @oas [method] path, but everything below it is a valid Path Definition.

You can also do inline parameters, which are shorthand for parameters. They aren't valid OpenAPI properties but swagger-inline knows how to compile them:

- (in) name=default* {type:format} Description

Host your API definition

Hosting API documentation is hard so, we have an online component that hosts your OpenAPI/Swagger file for you. Just type the following to get a URL:

oas host

This will upload your API definition and give you a public URL you can use.

Tooling

This library also exposes a set of tooling to help you manage OpenAPI definitions. You can access it by loading:

require('oas/tooling')

Components available are the following:

  • oas/tooling: An OAS class can help you discover operations within a large OpenAPI file.
  • oas/tooling/operation: An Operation class that can help you manage and retireve specific data from an API operation.
  • oas/tooling/utils
    • findSchemaDefinition: Function to assist with $ref lookups.
    • flattenSchema: Function to reduce a schema definition into a singular list.
    • getSchema: Retrieve the first requestBody schema on an operation.
    • parametersToJsonSchema: Warehouse method to reduce an operation down into a JSON Schema-compatible representation.

oas's People

Contributors

alansikora avatar dependabot-preview[bot] avatar dependabot[bot] avatar dpim avatar erunion avatar gkoberger avatar gratcliff avatar kanadgupta avatar mikeralphson avatar mjcuva avatar pvorb avatar

Watchers

 avatar

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.