/** * @since 1.0.0 */ import type { NonEmptyArray } from "effect/Array"; import * as Context from "effect/Context"; import * as HttpApi from "./HttpApi.js"; import type { HttpApiGroup } from "./HttpApiGroup.js"; import * as JsonSchema from "./OpenApiJsonSchema.js"; declare const Identifier_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class Identifier extends Identifier_base { } declare const Title_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class Title extends Title_base { } declare const Version_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class Version extends Version_base { } declare const Description_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class Description extends Description_base { } declare const License_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class License extends License_base { } declare const ExternalDocs_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class ExternalDocs extends ExternalDocs_base { } declare const Servers_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class Servers extends Servers_base { } declare const Format_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class Format extends Format_base { } declare const Summary_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class Summary extends Summary_base { } declare const Deprecated_base: Context.TagClass; /** * @since 1.0.0 * @category annotations */ export declare class Deprecated extends Deprecated_base { } declare const Override_base: Context.TagClass>; /** * @since 1.0.0 * @category annotations */ export declare class Override extends Override_base { } declare const Exclude_base: Context.ReferenceClass; /** * @since 1.0.0 * @category annotations */ export declare class Exclude extends Exclude_base { } declare const Transform_base: Context.TagClass) => Record>; /** * Transforms the generated OpenAPI specification * @since 1.0.0 * @category annotations */ export declare class Transform extends Transform_base { } /** * @since 1.0.0 * @category annotations */ 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; /** * @since 1.0.0 * @category models */ export type AdditionalPropertiesStrategy = "allow" | "strict"; /** * Converts an `HttpApi` instance into an OpenAPI Specification object. * * **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. Cached results are used for better performance when the same * `HttpApi` instance is processed multiple times. * * **Options** * * - `additionalPropertiesStrategy`: Controls the handling of additional properties. Possible values are: * - `"strict"`: Disallow additional properties (default behavior). * - `"allow"`: Allow additional properties. * * **Example** * * ```ts * import { HttpApi, HttpApiEndpoint, HttpApiGroup, OpenApi } from "@effect/platform" * import { Schema } from "effect" * * const api = HttpApi.make("api").add( * HttpApiGroup.make("group").add( * HttpApiEndpoint.get("get", "/items") * .addSuccess(Schema.Array(Schema.String)) * ) * ) * * const spec = OpenApi.fromApi(api) * * console.log(JSON.stringify(spec, null, 2)) * // Output: OpenAPI specification in JSON format * ``` * * @category constructors * @since 1.0.0 */ export declare const fromApi: (api: HttpApi.HttpApi, options?: { readonly additionalPropertiesStrategy?: AdditionalPropertiesStrategy | undefined; } | undefined) => 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`. * * @category models * @since 1.0.0 */ export interface OpenAPISpec { openapi: "3.1.0"; info: OpenAPISpecInfo; paths: OpenAPISpecPaths; components: OpenAPIComponents; security: Array; tags: Array; servers?: Array; } /** * @category models * @since 1.0.0 */ export interface OpenAPISpecInfo { title: string; version: string; description?: string; license?: OpenAPISpecLicense; summary?: string; } /** * @category models * @since 1.0.0 */ export interface OpenAPISpecTag { name: string; description?: string; externalDocs?: OpenAPISpecExternalDocs; } /** * @category models * @since 1.0.0 */ export interface OpenAPISpecExternalDocs { url: string; description?: string; } /** * @category models * @since 1.0.0 */ export interface OpenAPISpecLicense { name: string; url?: string; } /** * @category models * @since 1.0.0 */ export interface OpenAPISpecServer { url: string; description?: string; variables?: Record; } /** * @category models * @since 1.0.0 */ export interface OpenAPISpecServerVariable { default: string; enum?: NonEmptyArray; description?: string; } /** * @category models * @since 1.0.0 */ export type OpenAPISpecPaths = Record; /** * @category models * @since 1.0.0 */ export type OpenAPISpecMethodName = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace"; /** * @category models * @since 1.0.0 */ export type OpenAPISpecPathItem = { [K in OpenAPISpecMethodName]?: OpenAPISpecOperation; }; /** * @category models * @since 1.0.0 */ export interface OpenAPISpecParameter { name: string; in: "query" | "header" | "path" | "cookie"; schema: JsonSchema.JsonSchema; required: boolean; description?: string; } /** * @category models * @since 1.0.0 */ export type OpenAPISpecResponses = Record; /** * @category models * @since 1.0.0 */ export type OpenApiSpecContentType = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain"; /** * @category models * @since 1.0.0 */ export type OpenApiSpecContent = { [K in OpenApiSpecContentType]?: OpenApiSpecMediaType; }; /** * @category models * @since 1.0.0 */ export interface OpenApiSpecResponse { description: string; content?: OpenApiSpecContent; } /** * @category models * @since 1.0.0 */ export interface OpenApiSpecMediaType { schema: JsonSchema.JsonSchema; } /** * @category models * @since 1.0.0 */ export interface OpenAPISpecRequestBody { content: OpenApiSpecContent; required: true; } /** * @category models * @since 1.0.0 */ export interface OpenAPIComponents { schemas: Record; securitySchemes: Record; } /** * @category models * @since 1.0.0 */ export interface OpenAPIHTTPSecurityScheme { readonly type: "http"; scheme: "bearer" | "basic" | string; description?: string; bearerFormat?: string; } /** * @category models * @since 1.0.0 */ export interface OpenAPIApiKeySecurityScheme { readonly type: "apiKey"; name: string; in: "query" | "header" | "cookie"; description?: string; } /** * @category models * @since 1.0.0 */ export type OpenAPISecurityScheme = OpenAPIHTTPSecurityScheme | OpenAPIApiKeySecurityScheme; /** * @category models * @since 1.0.0 */ export type OpenAPISecurityRequirement = Record>; /** * @category models * @since 1.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