Skip to main content

OpenAPI

PrismOpenAPIGenerator produces OpenAPI 3.0 specifications from endpoint definitions, and PrismOpenAPIMiddleware serves them as JSON alongside a Swagger UI playground. Document your API once, get interactive docs and client generation for free.

Quick Setup

Serve API Docs

Defining Endpoints

Endpoint with Parameters

Parameters

Parameter Locations

Request Bodies

Request Body

Complete API Documentation

Full API Example

Custom Paths

Custom Spec and Docs Paths

Generate JSON Programmatically

Generate Spec
Keep your endpoint definitions close to your route definitions. Consider creating a function that registers both the route and its OpenAPI documentation at the same time to keep them in sync.
The Swagger UI is loaded from a CDN. Your server must have internet access for the docs page to render. The OpenAPI JSON spec at /openapi.json works offline.