Skip to main content
Version: Next

createValidatedOpenApiRouter()

Home > @backstage/backend-openapi-utils > createValidatedOpenApiRouter

Create a new OpenAPI router with some default middleware.

Signature:

function createValidatedOpenApiRouter<T extends RequiredDoc>(spec: T, options?: {
validatorOptions?: Partial<Parameters<typeof OpenApiValidator>['0']>;
middleware?: RequestHandler[];
}): ApiRouter<T>;

Parameters

Parameter

Type

Description

spec

T

Your OpenAPI spec imported as a JSON object.

options

{ validatorOptions?: Partial<Parameters<typeof OpenApiValidator>['0']>; middleware?: RequestHandler[]; }

(Optional)

**Returns:**

ApiRouter<T>

A new express router with validation middleware.