Skip to content
✨ Publier v1 is live — a polished docs platform built for the open web.
On this page

@publier/openapi

#### @publier/openapi

Overview

@publier/openapi

Modules

Interfaces

Types

EndpointKind

type EndpointKind = "path" | "webhook"

The kind of endpoint — a regular HTTP path, or an OpenAPI 3.1 webhook.

HttpMethod

type HttpMethod = "get" | "post" | "put" | "delete" | "patch" | "head" | "options"

Functions

asyncapiSource

function asyncapiSource(options: AsyncApiSourceOptions): ContentSource

Creates a ContentSource from a parsed AsyncAPI spec. Each channel becomes a virtual page grouped by tags.

Parameters

NameType
optionsAsyncApiSourceOptions

buildCodeSamples

function buildCodeSamples(method: HttpMethod, path: string, operation: OpenApiOperation, baseUrl: string, spec?: OpenApiSpec): { code: string; label: string; lang: SampleLang }[]

Build the full (lang, label, code) triple list the Rust renderer expects, in the canonical LANGUAGES order. Honors x-codeSamples overrides first, then falls back to auto-generation.

Parameters

NameType
methodHttpMethod
pathstring
operationOpenApiOperation
baseUrlstring
specOpenApiSpec

buildNavigation

function buildNavigation(spec: OpenApiSpec, options: BuildNavigationOptions = {}): NavigationGroup[]

Build a navigation tree suitable for feeding into a sidebar or custom page tree. Stateless and side-effect-free.

Parameters

NameTypeDefault
specOpenApiSpec
optionsBuildNavigationOptions{}

extractEndpoints

function extractEndpoints(spec: OpenApiSpec, options: ExtractEndpointsOptions = {}): EndpointEntry[]

Parameters

NameTypeDefault
specOpenApiSpec
optionsExtractEndpointsOptions{}

formatJson

function formatJson(value: unknown): string

Parameters

NameType
valueunknown

generateCodeSample

function generateCodeSample(method: HttpMethod, path: string, operation: OpenApiOperation, lang: SampleLang, baseUrl: string, spec?: OpenApiSpec): string

Parameters

NameType
methodHttpMethod
pathstring
operationOpenApiOperation
langSampleLang
baseUrlstring
specOpenApiSpec

generateExampleFromSchema

function generateExampleFromSchema(schema: OpenApiSchema): unknown

Parameters

NameType
schemaOpenApiSchema

getMediaTypeExample

function getMediaTypeExample(content: Record<string, OpenApiMediaType>, mediaType: string = 'application/json'): string | undefined

Parameters

NameTypeDefault
contentRecord<string, OpenApiMediaType>
mediaTypestring'application/json'

openapiSource

function openapiSource(options: OpenApiSourceOptions): ContentSource

Creates a ContentSource from a parsed OpenAPI spec. Each endpoint (method + path) becomes a virtual page grouped by tags.

Parameters

NameType
optionsOpenApiSourceOptions

Variables

HTTP_METHODS

const HTTP_METHODS = ...

HTTP methods that may appear on an OpenAPI path item, in canonical order.