Skip to content

OpenAPI Reference Plugin (Swagger/Scalar)

This plugin provides API reference documentation powered by Scalar, along with the OpenAPI specification in JSON format.

INFO

This plugin relies on the OpenAPI Generator. Please review its documentation before using this plugin.

Setup

ts
import { ZodToJsonSchemaConverter } from '@orpc/zod'
import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins'

const handler = new OpenAPIHandler(router, {
  plugins: [
    new OpenAPIReferencePlugin({
      schemaConverters: [
        new ZodToJsonSchemaConverter(),
      ],
      specGenerateOptions: {
        info: {
          title: 'ORPC Playground',
          version: '1.0.0',
        },
      },
    }),
  ]
})

INFO

By default, the API reference client is served at the root path (/), and the OpenAPI specification is available at /spec.json. You can customize these paths by providing the docsPath and specPath options.

Released under the MIT License.