Koa middleware to handle OpenAPI 3.x.
Last updated 2 years ago by confuser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install exegesis-koa 
SYNC missed versions from official npm registry.


Build Status Coverage Status Known Vulnerabilities


n. An explanation or critical interpretation of a text, especially an API definition document.

-- No dictionary ever

This library implements a Koa middleware for OpenAPI 3.x.

npm install exegesis-koa


Check out the tutorial here.


const Koa = require('koa')
const path = require('path')
const exegesisKoa = require('exegesis-koa')

async function createServer() {
    // See https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md
    const options = {
        controllers: path.resolve(__dirname, './controllers')
    const exegesisMiddleware = exegesisKoa(path.resolve(__dirname, './openapi.yaml'), options)

    const app = new Koa()

    // If you have any body parsers, this should go before them.
    app.use(async (ctx, next) => {
      try {
        await next()
      } catch (err) {
        ctx.status = 500
        ctx.body = `Internal error: ${err.message}`
    app.use(async (ctx) => {
      if (ctx.status === 404) {
        ctx.status = 404


Calling exegesiskoa(openApiFile, options) will return a Promise which resolves to a koa middleware.

openApiFile is either a path to your openapi.yaml or openapi.json file, or it can be a JSON object with the contents of your OpenAPI document. This should have the x-exegesis-controller extension defined on any paths you want to be able to access.

options can be anything you can pass to exegesis. At a minimum, you'll probably want to provide options.controllers, a path to where your controller modules can be found. If you have any security requirements defined, you'll also want to pass in some authenticators. To enable response validation, you'll want to provide a validation callback function via onResponseValidationError(). Exegesis's functionality can also be extended using plugins, which run on every request. Plugins let you add functionality like role base authorization, or CORS.

Current Tags

  • 0.0.1                                ...           latest (2 years ago)

1 Versions

  • 0.0.1                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (6)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |