@publier/openapi
#### @publier/openapi
Overview
@publier/openapi
Modules
Interfaces
APIPagePropsAPIPlaygroundPropsAPIReferencePropsAsyncApiChannelAsyncApiComponentsAsyncApiMessageAsyncApiOperationAsyncApiParameterAsyncApiServerAsyncApiSpecAsyncChannelPropsAsyncMessagePropsBuildNavigationOptionsCodeSamplesPropsEndpointEntry: A single endpoint extracted from an OpenAPI spec.ExtractEndpointsOptionsMethodBadgePropsNavigationGroup: A group of related endpoints — one per tag (default) or per first path segment. Maps naturally to a sidebar group entry.NavigationItem: A single navigation entry — typically one endpoint.OpenApiCodeSampleOpenApiComponentsOpenApiInfoOpenApiMediaTypeOpenApiOperationOpenApiParameterOpenApiPathItemOpenApiRequestBodyOpenApiResponseOpenApiSchemaOpenApiSecuritySchemeOpenApiServerOpenApiSpecOpenApiTagParamFieldPropsRequestExamplePropsResponseExamplePropsResponseFieldPropsSchemaViewProps
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
| Name | Type |
|---|---|
options | AsyncApiSourceOptions |
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
| Name | Type |
|---|---|
method | HttpMethod |
path | string |
operation | OpenApiOperation |
baseUrl | string |
spec | OpenApiSpec |
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
| Name | Type | Default |
|---|---|---|
spec | OpenApiSpec | |
options | BuildNavigationOptions | {} |
extractEndpoints
function extractEndpoints(spec: OpenApiSpec, options: ExtractEndpointsOptions = {}): EndpointEntry[]
Parameters
| Name | Type | Default |
|---|---|---|
spec | OpenApiSpec | |
options | ExtractEndpointsOptions | {} |
formatJson
function formatJson(value: unknown): string
Parameters
| Name | Type |
|---|---|
value | unknown |
generateCodeSample
function generateCodeSample(method: HttpMethod, path: string, operation: OpenApiOperation, lang: SampleLang, baseUrl: string, spec?: OpenApiSpec): string
Parameters
| Name | Type |
|---|---|
method | HttpMethod |
path | string |
operation | OpenApiOperation |
lang | SampleLang |
baseUrl | string |
spec | OpenApiSpec |
generateExampleFromSchema
function generateExampleFromSchema(schema: OpenApiSchema): unknown
Parameters
| Name | Type |
|---|---|
schema | OpenApiSchema |
getMediaTypeExample
function getMediaTypeExample(content: Record<string, OpenApiMediaType>, mediaType: string = 'application/json'): string | undefined
Parameters
| Name | Type | Default |
|---|---|---|
content | Record<string, OpenApiMediaType> | |
mediaType | string | '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
| Name | Type |
|---|---|
options | OpenApiSourceOptions |
Variables
HTTP_METHODS
const HTTP_METHODS = ...
HTTP methods that may appear on an OpenAPI path item, in canonical order.