Skip to main content
openapi-backend logo


CI npm version npm downloads GitHub stars License Buy me a coffee

Build, Validate, Route, Authenticate, and Mock using OpenAPI definitions.

OpenAPI Backend is a Framework-agnostic middleware tool for building beautiful APIs with OpenAPI Specification.


Quick Start

The easiest way to get started with OpenAPI Backend is to check out one of the examples.

npm install --save openapi-backend
import OpenAPIBackend from "openapi-backend";

// create api with your definition file or object
const api = new OpenAPIBackend({ definition: "./petstore.yml" });

// register your framework specific request handlers here
getPets: (c, req, res) => res.status(200).json({ result: "ok" }),
getPetById: (c, req, res) => res.status(200).json({ result: "ok" }),
notFound: (c, req, res) => res.status(404).json({ err: "not found" }),
validationFail: (c, req, res) =>
res.status(400).json({ err: c.validation.errors }),

// initalize the backend