Skip to content

OpenApiGenerator

The OpenApiGenerator module orchestrates converting OpenAPI and Swagger documents into generated Effect source.

It normalizes Swagger 2.0 input, resolves local references, builds the parsed operation model, registers request and response schemas, applies HttpApi-specific adaptations such as multipart helpers and security metadata, emits warnings for unsupported or lossy OpenAPI features, and then delegates final rendering to the HttpClient or HttpApi code generators.

8 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Constructs the OpenAPI generator service implementation.

Signature

declare const make: Effect<
{
generate: (...args: [_: OpenAPISpec, options: OpenApiGenerateOptions]) => Effect;
},
never,
never
>;

Layers

Layer providing an OpenAPI generator for Schema-backed HTTP client and HttpApi output.

Signature

declare const layerTransformerSchema: Layer.Layer<OpenApiGenerator>;

Layer providing an OpenAPI generator for type-only HTTP client output.

Signature

declare const layerTransformerTs: Layer.Layer<OpenApiGenerator>;

Models

Output targets supported by the OpenAPI generator.

Signature

type OpenApiGeneratorFormat = "httpclient" | "httpclient-type-only" | "httpapi";

OpenApiGeneratorWarning interface

Added in v4.0.0 Source

Describes a non-fatal issue encountered while mapping an OpenAPI operation to generated Effect source.

Signature

interface OpenApiGeneratorWarning {
readonly code: OpenApiGeneratorWarningCode;
readonly message: string;
readonly method?: OpenAPISpecMethodName;
readonly operationId?: string;
readonly path?: string;
}

Stable identifiers for non-fatal OpenAPI generation warnings.

Signature

type OpenApiGeneratorWarningCode =
| "cookie-parameter-dropped"
| "additional-tags-dropped"
| "sse-operation-skipped"
| "response-headers-ignored"
| "optional-request-body-approximated"
| "default-response-remapped"
| "security-and-downgraded"
| "no-body-method-request-body-skipped"
| "naming-collision";

Options

OpenApiGenerateOptions interface

Added in v4.0.0 Source

Options that control one OpenAPI generation run.

Signature

interface OpenApiGenerateOptions {
readonly format: OpenApiGeneratorFormat;
readonly name: string;
readonly onEnter?: (js: JsonSchema) => JsonSchema;
readonly onWarning?: (warning: OpenApiGeneratorWarning) => void;
}

Services

Service for turning OpenAPI or Swagger specifications into generated Effect HTTP client or HttpApi source code.

Signature

declare class OpenApiGenerator extends Shape<
"OpenApiGenerator",
{
readonly generate: (spec: OpenAPISpec, options: OpenApiGenerateOptions) => Effect<string>;
},
this
> {
constructor(_: never);
}