import { IJsonSchemaAttribute } from "../schema/IJsonSchemaAttribute"; import * as tags from "../tags"; /** * OpenAPI v3.1 specification types (raw, unemended). * * `OpenApiV3_1` contains TypeScript type definitions for raw OpenAPI v3.1 * documents as-is from the specification. Unlike {@link OpenApi}, this preserves * the original structure including `$ref` references and `allOf` compositions * without normalization. * * Key features in v3.1: * * - JSON Schema draft 2020-12 compatibility * - `type` can be an array: `type: ["string", "null"]` * - `const` keyword for constant values * - `prefixItems` for tuple definitions * - Webhooks support * * For a normalized format that simplifies schema processing, use * {@link OpenApi}. * * @author Jeongho Nam - https://github.com/samchon */ export declare namespace OpenApiV3_1 { /** HTTP method of the operation. */ type Method = "get" | "post" | "put" | "delete" | "options" | "head" | "patch" | "trace"; /** OpenAPI document structure. */ interface IDocument { /** OpenAPI version. */ openapi: `3.1.${number}`; /** List of servers. */ servers?: IServer[]; /** API metadata. */ info?: IDocument.IInfo; /** Reusable components. */ components?: IComponents; /** API paths and operations. */ paths?: Record; /** Webhook definitions. */ webhooks?: Record | IPath>; /** Global security requirements. */ security?: Record[]; /** Tag definitions. */ tags?: IDocument.ITag[]; } namespace IDocument { /** API metadata. */ interface IInfo { /** API title. */ title: string; /** Short summary. */ summary?: string; /** Full description. */ description?: string; /** Terms of service URL. */ termsOfService?: string; /** Contact information. */ contact?: IContact; /** License information. */ license?: ILicense; /** API version. */ version: string; } /** Tag for grouping operations. */ interface ITag { /** Tag name. */ name: string; /** Tag description. */ description?: string; } /** Contact information. */ interface IContact { /** Contact name. */ name?: string; /** Contact URL. */ url?: string; /** Contact email. */ email?: string & tags.Format<"email">; } /** License information. */ interface ILicense { /** License name. */ name: string; /** SPDX license identifier. */ identifier?: string; /** License URL. */ url?: string; } } /** Server providing the API. */ interface IServer { /** Server URL. */ url: string; /** Server description. */ description?: string; /** URL template variables. */ variables?: Record; } namespace IServer { /** URL template variable. */ interface IVariable { /** Default value. */ default: string; /** Allowed values. @minItems 1 */ enum?: string[]; /** Variable description. */ description?: string; } } /** Path item containing operations by HTTP method. */ interface IPath extends Partial> { /** Path-level parameters. */ parameters?: Array | IJsonSchema.IReference<`#/components/parameters/${string}`>>; /** Path-level servers. */ servers?: IServer[]; /** Path summary. */ summary?: string; /** Path description. */ description?: string; /** * Non-standard HTTP method operations (extension). * * Used when downgrading from OpenAPI v3.2 to preserve non-standard methods * like `query` or custom methods. */ "x-additionalOperations"?: Record; } /** API operation metadata. */ interface IOperation { /** Unique operation identifier. */ operationId?: string; /** Operation parameters. */ parameters?: Array | IJsonSchema.IReference<`#/components/parameters/${string}`>>; /** Request body. */ requestBody?: IOperation.IRequestBody | IJsonSchema.IReference<`#/components/requestBodies/${string}`>; /** Response definitions by status code. */ responses?: Record>; /** Operation-level servers. */ servers?: IServer[]; /** Short summary. */ summary?: string; /** Full description. */ description?: string; /** Security requirements. */ security?: Record[]; /** Operation tags. */ tags?: string[]; /** Whether deprecated. */ deprecated?: boolean; } namespace IOperation { /** Operation parameter. */ interface IParameter { /** Parameter name. */ name?: string; /** Parameter location. */ in: "path" | "query" | "header" | "cookie"; /** Parameter schema. */ schema: IJsonSchema; /** Whether required. */ required?: boolean; /** Parameter description. */ description?: string; /** Example value. */ example?: any; /** Named examples. */ examples?: Record>; } /** Request body. */ interface IRequestBody { /** Body description. */ description?: string; /** Whether required. */ required?: boolean; /** Body content by media type. */ content?: Record; } /** Response definition. */ interface IResponse { /** Response content by media type. */ content?: Record; /** Response headers. */ headers?: Record | IJsonSchema.IReference<`#/components/headers/${string}`>>; /** Response description. */ description?: string; } /** Media type definition. */ interface IMediaType { /** Content schema. */ schema?: IJsonSchema; /** Example value. */ example?: any; /** Named examples. */ examples?: Record>; } } /** Example value definition. */ interface IExample { /** Example summary. */ summary?: string; /** Example description. */ description?: string; /** Example value. */ value?: any; /** External value URL. */ externalValue?: string; } /** Reusable components storage. */ interface IComponents { /** Named schemas. */ schemas?: Record; /** Named path items. */ pathItems?: Record; /** Named responses. */ responses?: Record; /** Named parameters. */ parameters?: Record; /** Named request bodies. */ requestBodies?: Record; /** Named security schemes. */ securitySchemes?: Record; /** Named headers. */ headers?: Record>; /** Named examples. */ examples?: Record; } /** JSON Schema type for OpenAPI v3.1. */ type IJsonSchema = IJsonSchema.IMixed | IJsonSchema.IConstant | IJsonSchema.IBoolean | IJsonSchema.IInteger | IJsonSchema.INumber | IJsonSchema.IString | IJsonSchema.IArray | IJsonSchema.IObject | IJsonSchema.IReference | IJsonSchema.IRecursiveReference | IJsonSchema.IAllOf | IJsonSchema.IAnyOf | IJsonSchema.IOneOf | IJsonSchema.INull | IJsonSchema.IUnknown; namespace IJsonSchema { /** Mixed type (multiple types in array). */ interface IMixed extends IConstant, Omit, Omit, Omit, Omit, Omit, IOneOf, IAnyOf, IAllOf, IReference { /** Array of type discriminators. */ type: Array<"boolean" | "integer" | "number" | "string" | "array" | "object" | "null">; /** Default value. */ default?: any[] | null; /** Allowed values. */ enum?: any[]; } /** Constant value type. */ interface IConstant extends __IAttribute { /** Constant value. */ const: boolean | number | string; /** Whether nullable. */ nullable?: boolean; } /** Boolean type. */ interface IBoolean extends Omit, __IAttribute { /** Whether nullable. */ nullable?: boolean; /** Default value. */ default?: boolean | null; /** Allowed values. */ enum?: Array; } /** Integer type. */ interface IInteger extends Omit, __IAttribute { /** Whether nullable. */ nullable?: boolean; /** Default value. */ default?: (number & tags.Type<"int64">) | null; /** Allowed values. */ enum?: Array<(number & tags.Type<"int64">) | null>; /** Minimum value. */ minimum?: number & tags.Type<"int64">; /** Maximum value. */ maximum?: number & tags.Type<"int64">; /** Exclusive minimum. */ exclusiveMinimum?: (number & tags.Type<"int64">) | boolean; /** Exclusive maximum. */ exclusiveMaximum?: (number & tags.Type<"int64">) | boolean; /** Multiple of constraint. */ multipleOf?: number & tags.ExclusiveMinimum<0>; } /** Number (double) type. */ interface INumber extends Omit, __IAttribute { /** Whether nullable. */ nullable?: boolean; /** Default value. */ default?: number | null; /** Allowed values. */ enum?: Array; /** Minimum value. */ minimum?: number; /** Maximum value. */ maximum?: number; /** Exclusive minimum. */ exclusiveMinimum?: number | boolean; /** Exclusive maximum. */ exclusiveMaximum?: number | boolean; /** Multiple of constraint. */ multipleOf?: number & tags.ExclusiveMinimum<0>; } /** String type. */ interface IString extends Omit, __IAttribute { /** Whether nullable. */ nullable?: boolean; /** Default value. */ default?: string | null; /** Allowed values. */ enum?: Array; /** String format. */ format?: "binary" | "byte" | "password" | "regex" | "uuid" | "email" | "hostname" | "idn-email" | "idn-hostname" | "iri" | "iri-reference" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "uri-template" | "url" | "date-time" | "date" | "time" | "duration" | "json-pointer" | "relative-json-pointer" | (string & {}); /** Regex pattern. */ pattern?: string; /** Content media type. */ contentMediaType?: string; /** Minimum length. */ minLength?: number & tags.Type<"uint64">; /** Maximum length. */ maxLength?: number & tags.Type<"uint64">; } /** Object type. */ interface IObject extends Omit, __IAttribute { /** Whether nullable. */ nullable?: boolean; /** Property schemas. */ properties?: Record; /** Required property names. */ required?: string[]; /** Additional properties schema. */ additionalProperties?: boolean | IJsonSchema; /** Maximum properties. */ maxProperties?: number; /** Minimum properties. */ minProperties?: number; } /** Array type. */ interface IArray extends Omit, __IAttribute { /** Whether nullable. */ nullable?: boolean; /** Element type (or tuple types). */ items?: IJsonSchema | IJsonSchema[]; /** Tuple prefix items. */ prefixItems?: IJsonSchema[]; /** Whether elements must be unique. */ uniqueItems?: boolean; /** Additional items schema. */ additionalItems?: boolean | IJsonSchema; /** Minimum items. */ minItems?: number & tags.Type<"uint64">; /** Maximum items. */ maxItems?: number & tags.Type<"uint64">; } /** Reference to a named schema. */ interface IReference extends __IAttribute { /** Reference path. */ $ref: Key; } /** Recursive reference. */ interface IRecursiveReference extends __IAttribute { /** Recursive reference path. */ $recursiveRef: string; } /** All-of combination. */ interface IAllOf extends __IAttribute { /** Schemas to combine. */ allOf: IJsonSchema[]; } /** Any-of union. */ interface IAnyOf extends __IAttribute { /** Union member schemas. */ anyOf: IJsonSchema[]; } /** One-of union. */ interface IOneOf extends __IAttribute { /** Union member schemas. */ oneOf: IJsonSchema[]; /** Discriminator for tagged unions. */ discriminator?: IOneOf.IDiscriminator; } namespace IOneOf { /** Discriminator for tagged unions. */ interface IDiscriminator { /** Discriminator property name. */ propertyName: string; /** Value to schema mapping. */ mapping?: Record; } } /** Null type. */ interface INull extends Omit, __IAttribute { /** Default value. */ default?: null; } /** Unknown type. */ interface IUnknown extends Omit, __IAttribute { /** Type discriminator (undefined for unknown). */ type?: undefined; /** Default value. */ default?: any; } /** @ignore Base Attribute interface. */ interface __IAttribute extends Omit { /** Example values. */ examples?: any[] | Record; } } /** Security scheme types. */ type ISecurityScheme = ISecurityScheme.IApiKey | ISecurityScheme.IHttpBasic | ISecurityScheme.IHttpBearer | ISecurityScheme.IOAuth2 | ISecurityScheme.IOpenId; namespace ISecurityScheme { /** API key authentication. */ interface IApiKey { /** Scheme type. */ type: "apiKey"; /** Key location. */ in?: "header" | "query" | "cookie"; /** Key name. */ name?: string; /** Scheme description. */ description?: string; } /** HTTP basic authentication. */ interface IHttpBasic { /** Scheme type. */ type: "http"; /** Authentication scheme. */ scheme: "basic"; /** Scheme description. */ description?: string; } /** HTTP bearer authentication. */ interface IHttpBearer { /** Scheme type. */ type: "http"; /** Authentication scheme. */ scheme: "bearer"; /** Bearer token format hint. */ bearerFormat?: string; /** Scheme description. */ description?: string; } /** OAuth2 authentication. */ interface IOAuth2 { /** Scheme type. */ type: "oauth2"; /** OAuth2 flows. */ flows: IOAuth2.IFlowSet; /** Scheme description. */ description?: string; } /** OpenID Connect authentication. */ interface IOpenId { /** Scheme type. */ type: "openIdConnect"; /** OpenID Connect discovery URL. */ openIdConnectUrl: string; /** Scheme description. */ description?: string; } namespace IOAuth2 { /** OAuth2 flow configurations. */ interface IFlowSet { /** Authorization code flow. */ authorizationCode?: IFlow; /** Implicit flow. */ implicit?: Omit; /** Password flow. */ password?: Omit; /** Client credentials flow. */ clientCredentials?: Omit; } /** OAuth2 flow configuration. */ interface IFlow { /** Authorization URL. */ authorizationUrl?: string; /** Token URL. */ tokenUrl?: string; /** Refresh URL. */ refreshUrl?: string; /** Available scopes. */ scopes?: Record; } } } }