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 1,000,000+ packages pre-installed, including baucis-openapi3 with all npm packages installed. Try it out:

require("mongoose/package.json"); // mongoose is a peer dependency. require("baucis/package.json"); // baucis is a peer dependency. var baucisOpenapi3 = require("baucis-openapi3")

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

baucis-openapi3 v0.3.0

Generate customizable OpenAPI version 3.0.0 definitions for your Baucis REST API.


Build Status Coverage Status Dependency Status Known Vulnerabilities npm version Greenkeeper badge


This module generates customizable OpenAPI 3.0 definitions for your Baucis API. Use this module in conjunction with Baucis.


Install with:

npm install --save baucis baucis-openapi3

Include the package after baucis is included, and before your API is built.

    var express = require('express');
    var baucis = require('baucis');
    var apiDoc = require('baucis-openapi3');

    var app = express();

    // ... Set up a mongoose schema ...'vegetable');
    app.use('/api', baucis());

Then, access e.g. GET http://localhost:3333/api/openapi.json. See the Baucis repo for more information about building REST APIs with Baucis.


Change the test/fixures/config.json if needed, to point to a valid mongodb database. Then run:

npm test


If you want to modify the OpenAPI definition, generate the definition first. (This will happen automatically otherwise.)

Use the openApi3 member of the controller to extend paths and components per controller.

controller.generateOpenApi3(); = '123'; = {};

Or use the openApi3Document of the baucis instance module to access and modify dirrecty the full document after calling generateOpenApi3() on the API.

var baucisInstance = baucis();

//generate standard template for OpenAPI3
//extend OpenAPI3 definitions = "myApi";

app.use('/api', baucisInstance);

Backward compatibility

In case you want to provide an easy transition as possible for your current API clients. You can expose both API descriptions at the same time including both modules:

    var express = require('express');
    var baucis = require('baucis');
    var swagger = require('baucis-swagger');
    var swagger2 = require('baucis-swagger2');
    var openapi3 = require('baucis-openapi3');

    var app = express();

    // ... Set up a mongoose schema ...'vegetable');
    app.use('/api', baucis());

After that:

  • Swagger 1.1 doc will be exposed at /api/documentation
  • Swagger 2.0 doc will be exposed at /api/swagger.json
  • OpenAPI 3.0 doc will be exposed at /api/openapi.json


Released under MIT License. © 2017-2018 Metadev

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