OpenApiGenerateContext
Shared mutable context object threaded through every mapper call during a single OpenApiDocumentFactory.generate() run. Holds the target version, the components.schemas map being filled in, name-collision bookkeeping, and the warnings list.
import { OpenApiGenerateContext } from '@opra/openapi';
This class is used internally by OpenApiDocumentFactory. You only need it directly if you are writing custom mapper extensions.
Constructor
new OpenApiGenerateContext(options?: { version?: '3.0' | '3.1'; scope?: string })
| Parameter | Type | Default | Description |
|---|---|---|---|
version | '3.0' | '3.1' | '3.0' | Target OpenAPI version. |
scope | string | undefined | Scope filter applied to types and fields. |
Properties
| Property | Type | Description |
|---|---|---|
version | '3.0' | '3.1' | The target OpenAPI version. |
scope | string | undefined | The scope filter. |
schemas | Record<string, OpenApi.SchemaObject> | The components.schemas map being built. |
warnings | string[] | Warnings accumulated during generation. |
Methods
getSchemaName(dataType)
getSchemaName(dataType: DataType): string | undefined
Returns the $ref-safe component name for a named DataType, registering it on first use and deduplicating collisions by appending a numeric suffix. Returns undefined for anonymous types — callers inline those instead of referencing.
hasSchema(name)
hasSchema(name: string): boolean
Returns true if a schema with the given name is already registered in components.schemas.
warn(message)
warn(message: string): void
Appends a warning string to the warnings array.