Skip to main content
openapi-backend logo

openapi-backendGitHub

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.

Battle-tested in production. See who uses openapi-stack →

Features

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
api.register({
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
api.init();

Contributors

openapi-backend is built by dozens of contributors across the openapi-stack project.

openapi-backend contributors