import type { NonEmptyArray } from "../Array.ts"; import * as Context from "../Context.ts"; import * as HttpMethod from "../http/HttpMethod.ts"; import * as JsonSchema from "../JsonSchema.ts"; import * as Schema from "../Schema.ts"; import type * as SchemaRepresentation from "../SchemaRepresentation.ts"; import * as HttpApi from "./HttpApi.ts"; import type * as HttpApiGroup from "./HttpApiGroup.ts"; declare const Identifier_base: Context.ServiceClass; /** * OpenAPI annotation for overriding generated identifiers, including operation ids. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Identifier extends Identifier_base { } declare const Title_base: Context.ServiceClass; /** * OpenAPI annotation for setting the API title or group tag name. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Title extends Title_base { } declare const Version_base: Context.ServiceClass; /** * OpenAPI annotation for setting the generated API version. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Version extends Version_base { } declare const Description_base: Context.ServiceClass; /** * OpenAPI annotation for setting generated descriptions on APIs, groups, endpoints, or security schemes. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Description extends Description_base { } declare const License_base: Context.ServiceClass; /** * OpenAPI annotation for setting the generated API license metadata. * * @stability unstable * @category services * @since 4.0.0 */ export declare class License extends License_base { } declare const ExternalDocs_base: Context.ServiceClass; /** * OpenAPI annotation for adding external documentation metadata to groups or endpoints. * * @stability unstable * @category services * @since 4.0.0 */ export declare class ExternalDocs extends ExternalDocs_base { } declare const Servers_base: Context.ServiceClass; /** * OpenAPI annotation for setting the generated API server list. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Servers extends Servers_base { } declare const Format_base: Context.ServiceClass; /** * OpenAPI annotation for setting the format metadata, such as a bearer token format on security schemes. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Format extends Format_base { } declare const Summary_base: Context.ServiceClass; /** * OpenAPI annotation for setting generated summary text. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Summary extends Summary_base { } declare const Deprecated_base: Context.ServiceClass; /** * OpenAPI annotation for marking a generated endpoint operation as deprecated. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Deprecated extends Deprecated_base { } declare const Override_base: Context.ServiceClass>; /** * OpenAPI annotation for shallowly merging additional fields into a generated OpenAPI object. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Override extends Override_base { } /** * Annotation that excludes an annotated group or endpoint from the generated * OpenAPI specification. * * **When to use** * * Use to hide internal, experimental, or otherwise undocumented HTTP API groups * and endpoints from generated OpenAPI output. * * @stability unstable * @category services * @since 4.0.0 */ export declare const Exclude: Context.Reference; declare const Transform_base: Context.ServiceClass) => Record>; /** * OpenAPI annotation for transforming a generated OpenAPI object. * * **Details** * * The function is applied during generation to the annotated API, group tag, or * endpoint operation. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Transform extends Transform_base { } /** * Builds a `Context` containing OpenAPI annotations from the supplied options. * * @stability unstable * @category annotations * @since 4.0.0 */ export declare const annotations: (options: { readonly identifier?: string | undefined; readonly title?: string | undefined; readonly version?: string | undefined; readonly description?: string | undefined; readonly license?: OpenAPISpecLicense | undefined; readonly summary?: string | undefined; readonly deprecated?: boolean | undefined; readonly externalDocs?: OpenAPISpecExternalDocs | undefined; readonly servers?: ReadonlyArray | undefined; readonly format?: string | undefined; readonly override?: Record | undefined; readonly exclude?: boolean | undefined; readonly transform?: ((openApiSpec: Record) => Record) | undefined; }) => Context.Context; /** * Options for {@link fromApi}. * * @stability unstable * @category models * @since 4.0.6 */ export interface FromApiOptions extends SchemaRepresentation.ToRepresentationOptions, Pick { } /** * Generates an OpenAPI 3.1 specification from an `HttpApi`. * * **When to use** * * Use when you need a programmatic OpenAPI document for an API definition. * * **Details** * * This function takes an `HttpApi` instance, which defines a structured API, * and generates an OpenAPI Specification (`OpenAPISpec`). The resulting spec * adheres to the OpenAPI 3.1.0 standard and includes detailed metadata such as * paths, operations, security schemes, and components. The function processes * the API's annotations, middleware, groups, and endpoints to build a complete * and accurate representation of the API in OpenAPI format. * * The function also deduplicates schemas, applies transformations, and * integrates annotations like descriptions, summaries, external documentation, * and overrides. The optional reference policy receives canonical JSON encoded * ASTs and controls which schemas are extracted into components. By default, only candidates with resolved identifiers * become references; anonymous non-recursive schemas remain inline. The optional `includeAnnotationKey` predicate selects * custom schema annotation keys, such as `x-*` vendor extensions, to include in the generated schemas. * * **Gotchas** * * Cached results are keyed by both the `HttpApi` instance and the identity of the options object. Reuse the same immutable * options object to reuse a cached result; mutating an options object after its first use does not invalidate the cached * specification. Each call returns a copy of the cached specification. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare function fromApi(api: HttpApi.HttpApi, options?: FromApiOptions): OpenAPISpec; /** * This model describes the OpenAPI specification (version 3.1.0) returned by * {@link fromApi}. It is not intended to describe the entire OpenAPI * specification, only the output of `fromApi`. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpec { openapi: "3.1.0"; info: OpenAPISpecInfo; paths: OpenAPISpecPaths; components: OpenAPIComponents; security: Array; tags: Array; servers?: Array; } /** * OpenAPI `info` object generated by `fromApi`. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpecInfo { title: string; version: string; description?: string; license?: OpenAPISpecLicense; summary?: string; } /** * OpenAPI tag object generated for an HTTP API group. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpecTag { name: string; description?: string; externalDocs?: OpenAPISpecExternalDocs; } /** * OpenAPI external documentation metadata. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpecExternalDocs { url: string; description?: string; } /** * OpenAPI license metadata used in the generated `info` object. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpecLicense { name: string; url?: string; [key: string]: unknown; } /** * OpenAPI server object used in the generated `servers` array. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpecServer { url: string; description?: string; variables?: Record; } /** * OpenAPI variable definition for templated server URLs. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpecServerVariable { default: string; enum?: NonEmptyArray; description?: string; } /** * Generated OpenAPI `paths` object, keyed by route path. * * @stability unstable * @category models * @since 4.0.0 */ export type OpenAPISpecPaths = Record; /** * Lowercase HTTP method names used as keys in generated OpenAPI path items. * * @stability unstable * @category models * @since 4.0.0 */ export type OpenAPISpecMethodName = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace"; /** * Generated OpenAPI path item mapping HTTP methods to operations for a single route path. * Parameters declared here are shared by every operation on the path. * `QUERY` operations are emitted under `x-oai-additionalOperations`. * * @stability unstable * @category models * @since 4.0.0 */ export type OpenAPISpecPathItem = { [K in OpenAPISpecMethodName]?: OpenAPISpecOperation; } & { parameters?: Array; "x-oai-additionalOperations"?: Partial>; }; /** * Generated OpenAPI parameter object for path, query, header, or cookie parameters. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpecParameter { name: string; in: "query" | "header" | "path" | "cookie"; schema: object; required: boolean; description?: string; } /** * Generated OpenAPI responses object, keyed by HTTP status code. * * @stability unstable * @category models * @since 4.0.0 */ export type OpenAPISpecResponses = Record; /** * Generated OpenAPI content object, keyed by media type. * * @stability unstable * @category models * @since 4.0.0 */ export type OpenApiSpecContent = { [K in string]: OpenApiSpecMediaType; }; /** * Generated OpenAPI response object for an endpoint success or error schema. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenApiSpecResponse { description: string; content?: OpenApiSpecContent; headers?: Record; } /** * Generated OpenAPI response header object. * * @stability unstable * @category models * @since 4.0.0 */ export type OpenAPISpecHeader = Omit; /** * Generated OpenAPI media type object containing the JSON Schema for a request or response body. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenApiSpecMediaType { schema: JsonSchema.JsonSchema; "x-effect-stream"?: OpenApiSpecEffectStream; } /** * Effect-specific metadata for generated streaming request and response media * types. * * @stability unstable * @category models * @since 4.0.0 */ export type OpenApiSpecEffectStream = { encoding: "sse"; causeSchema: JsonSchema.JsonSchema; errorSchema: JsonSchema.JsonSchema; failureEvent: "effect/http-api/stream/failure"; } | { encoding: "uint8array"; } | { encoding: "ndjson"; }; /** * Generated OpenAPI request body object for endpoint payloads. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpecRequestBody { content: OpenApiSpecContent; required: true; } /** * Generated OpenAPI components containing shared schemas and security schemes. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPIComponents { schemas: JsonSchema.Definitions; securitySchemes: Record; } /** * Generated OpenAPI HTTP security scheme, such as bearer or basic authentication. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPIHTTPSecurityScheme { readonly type: "http"; scheme: "bearer" | "basic" | string; description?: string; bearerFormat?: string; } /** * Generated OpenAPI API key security scheme. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPIApiKeySecurityScheme { readonly type: "apiKey"; name: string; in: "query" | "header" | "cookie"; description?: string; } /** * Union of security scheme objects emitted in generated OpenAPI components. * * @stability unstable * @category models * @since 4.0.0 */ export type OpenAPISecurityScheme = OpenAPIHTTPSecurityScheme | OpenAPIApiKeySecurityScheme; /** * Generated OpenAPI security requirement, keyed by security scheme name. * * @stability unstable * @category models * @since 4.0.0 */ export type OpenAPISecurityRequirement = Record>; /** * Generated OpenAPI operation object for an HTTP API endpoint. * * @stability unstable * @category models * @since 4.0.0 */ export interface OpenAPISpecOperation { operationId: string; parameters: Array; responses: OpenAPISpecResponses; /** Always contains at least the title annotation or the group identifier */ tags: NonEmptyArray; security: Array; requestBody?: OpenAPISpecRequestBody; description?: string; summary?: string; deprecated?: boolean; externalDocs?: OpenAPISpecExternalDocs; } export {}; //# sourceMappingURL=OpenApi.d.ts.map