Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including oas with all npm packages installed. Try it out:

var oas = require("oas")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

oas v0.8.18

A collection of Open API Initiative (Swagger) tools

oas

Creating Swagger / OpenAPI Spec files is hard. This makes it easier.

This tool currently supports Swagger 2 and OAS 3.

Installation

npm install oas -g

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

Rather than trying to juggle one gigantic repo, oas uses something called swagger-inline. It lets you include a little swagger snippet in a comment above your code, and collects them all together into one Swagger 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 Swagger Path Definition.

You can also do inline parameters, which are shorthand for parameters. They aren't valid Swagger, however Swagger Inline knows how to compile them:

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

Host your Swagger file

Hosting Swagger files is hard! So, we have an online component that hosts your Swagger file for you. Just type the following to get a URL:

oas host

This will upload your Swagger file and give you a URL you can use.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free