interface Dictionary { [key: string]: T; } interface WithEnumExtension { 'x-enumNames'?: ReadonlyArray; 'x-enum-descriptions'?: ReadonlyArray; 'x-enum-varnames'?: ReadonlyArray; } /** * {@link} https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#external-documentation-object */ interface OpenApiExternalDocs { description?: string; url: string; } /** * {@link} https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#reference-object */ interface OpenApiReference { $ref?: string; } /** * {@link} https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#example-object */ interface OpenApiExample extends OpenApiReference { summary?: string; description?: string; value?: unknown; externalValue?: string; } /** * {@link} https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#discriminator-object */ interface OpenApiDiscriminator { propertyName: string; mapping?: Dictionary; } /** * {@link} https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#xml-object */ interface OpenApiXml { name?: string; namespace?: string; prefix?: string; attribute?: boolean; wrapped?: boolean; } /** * {@link} https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schema-object */ interface OpenApiSchema extends OpenApiReference, WithEnumExtension { additionalProperties?: boolean | OpenApiSchema; allOf?: OpenApiSchema[]; anyOf?: OpenApiSchema[]; const?: string | number | boolean | null; default?: unknown; deprecated?: boolean; description?: string; discriminator?: OpenApiDiscriminator; enum?: (string | number)[]; example?: unknown; exclusiveMaximum?: boolean; exclusiveMinimum?: boolean; externalDocs?: OpenApiExternalDocs; format?: 'binary' | 'boolean' | 'byte' | 'date-time' | 'date' | 'double' | 'float' | 'int32' | 'int64' | 'password' | 'string'; items?: OpenApiSchema; maximum?: number; maxItems?: number; maxLength?: number; maxProperties?: number; minimum?: number; minItems?: number; minLength?: number; minProperties?: number; multipleOf?: number; not?: OpenApiSchema[]; nullable?: boolean; oneOf?: OpenApiSchema[]; pattern?: string; prefixItems?: OpenApiSchema[]; properties?: Dictionary; readOnly?: boolean; required?: string[]; title?: string; type?: string | string[]; uniqueItems?: boolean; writeOnly?: boolean; xml?: OpenApiXml; } /** * add only one type for now as that's needed to resolve the reported issue, * more types should be added though * {@link https://github.com/hey-api/openapi-ts/issues/612} */ type MediaType = 'application/json'; /** * encoding interface should be added, not adding it for now as it's not needed * to resolve the issue reported * {@link https://github.com/hey-api/openapi-ts/issues/612} */ interface MediaTypeObject { example?: unknown; examples?: Dictionary; schema: OpenApiSchema; } /** * {@link} https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameter-object */ interface OpenApiParameter extends OpenApiReference { allowEmptyValue?: boolean; allowReserved?: boolean; content?: Record; deprecated?: boolean; description?: string; example?: unknown; examples?: Dictionary; explode?: boolean; in: 'cookie' | 'formData' | 'header' | 'path' | 'query'; name: string; nullable?: boolean; required?: boolean; schema?: OpenApiSchema; style?: string; } interface Enum { customDescription?: string; customName?: string; description?: string; value: string | number; } interface OperationParameter extends Model { in: 'body' | 'cookie' | 'formData' | 'header' | 'path' | 'query'; prop: string; mediaType: string | null; } interface OperationParameters extends Pick { parameters: OperationParameter[]; parametersBody: OperationParameter | null; parametersCookie: OperationParameter[]; parametersForm: OperationParameter[]; parametersHeader: OperationParameter[]; parametersPath: OperationParameter[]; parametersQuery: OperationParameter[]; } interface OperationResponse extends Model { in: 'header' | 'response'; code: number | 'default' | '1XX' | '2XX' | '3XX' | '4XX' | '5XX'; responseTypes: Array<'error' | 'success'>; } type Method = 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE'; interface Operation extends OperationParameters { deprecated: boolean; description: string | null; /** * The operationId from OpenAPI specification. */ id: string | null; method: Method; /** * Method name. Methods contain the request logic. */ name: string; path: string; responseHeader: string | null; /** * All operation responses defined in OpenAPI specification. * Sorted by status code. */ responses: OperationResponse[]; /** * Service name, might be without postfix. This will be used to name the * exported class. */ service: string; summary: string | null; } interface Schema { default?: unknown; exclusiveMaximum?: boolean; exclusiveMinimum?: boolean; format?: 'binary' | 'boolean' | 'byte' | 'date-time' | 'date' | 'double' | 'float' | 'int32' | 'int64' | 'password' | 'string'; isDefinition: boolean; isNullable: boolean; isReadOnly: boolean; isRequired: boolean; maximum?: number; maxItems?: number; maxLength?: number; maxProperties?: number; minimum?: number; minItems?: number; minLength?: number; minProperties?: number; multipleOf?: number; pattern?: string; uniqueItems?: boolean; } interface ModelMeta { /** * Ref to the type in OpenAPI specification. */ $ref: string; /** * Name passed to the initial `getModel()` call. */ name: string; } interface Model extends Schema { /** * **Experimental.** Contains list of original refs so they can be used * to access the schema from anywhere instead of relying on string name. * This allows us to do things like detect type of ref. */ $refs: string[]; base: string; deprecated?: boolean; description: string | null; enum: Enum[]; enums: Model[]; export: 'all-of' | 'any-of' | 'array' | 'const' | 'dictionary' | 'enum' | 'generic' | 'interface' | 'one-of' | 'reference'; imports: string[]; in: OperationParameter['in'] | OpenApiParameter['in'] | OperationResponse['in'] | ''; link: Model | Model[] | null; meta?: ModelMeta; /** * @deprecated use `meta.name` instead */ name: string; properties: Model[]; template: string | null; type: string; } interface Service extends Pick { operations: Operation[]; } interface Client { models: Model[]; server: string; services: Service[]; /** * Map of generated types where type names are keys. This is used to track * uniquely generated types as we may want to deduplicate if there are * multiple definitions with the same name but different value, or if we * want to transform names. */ types: Record; version: string; } interface ClientConfig { /** * Manually set base in OpenAPI config instead of inferring from server value * @deprecated */ base?: string; /** * HTTP client to generate * @default 'fetch' */ client?: '@hey-api/client-axios' | '@hey-api/client-fetch' | 'angular' | 'axios' | 'fetch' | 'node' | 'xhr'; /** * Path to the config file. Set this value if you don't use the default * config file name, or it's not located in the project root. */ configFile?: string; /** * Run in debug mode? * @default false */ debug?: boolean; /** * Skip writing files to disk? * @default false */ dryRun?: boolean; /** * Generate core client classes? * @default true */ exportCore?: boolean; /** * The relative location of the OpenAPI spec */ input: string | Record; /** * Custom client class name * @deprecated */ name?: string; /** * The relative location of the output directory */ output: string | { /** * Process output folder with formatter? * @default false */ format?: 'biome' | 'prettier' | false; /** * Process output folder with linter? * @default false */ lint?: 'biome' | 'eslint' | false; /** * The relative location of the output directory */ path: string; }; /** * Path to custom request file * @deprecated */ request?: string; /** * Generate JSON schemas? * @default true */ schemas?: boolean | { /** * Generate JSON schemas? * @default true */ export?: boolean; /** * Choose schema type to generate. Select 'form' if you don't want * descriptions to reduce bundle size and you plan to use schemas * for form validation * @default 'json' */ type?: 'form' | 'json'; }; /** * Generate services? * @default true */ services?: boolean | string | { /** * Group operation methods into service classes? When enabled, you can * select which classes to export with `services.include` and/or * transform their names with `services.name`. * * Note that by enabling this option, your services will **NOT** * support {@link https://developer.mozilla.org/docs/Glossary/Tree_shaking tree-shaking}. * For this reason, it is disabled by default. * @default false */ asClass?: boolean; /** * Generate services? * @default true */ export?: boolean; /** * Include only service classes with names matching regular expression * * This option has no effect if `services.asClass` is `false`. */ include?: string; /** * Customize the generated service class names. The name variable is * obtained from your OpenAPI specification tags. * * This option has no effect if `services.asClass` is `false`. * @default '{{name}}Service' */ name?: string; /** * Customise the method name of methods within the service. By default, {@link Operation.name} is used. */ methodNameBuilder?: (operation: Operation) => string; /** * 使用summary作为方法名 * @default true */ useSummaryAsName?: boolean; /** * Use operation ID to generate operation names? * @default true */ operationId?: boolean; /** * Define shape of returned value from service calls * @default 'body' * @deprecated */ response?: 'body' | 'response'; }; /** * Generate types? * @default true */ types?: boolean | string | { /** * Output Date type and possibly runtime transform instead of string for format "date-time" * @default false */ dates?: boolean | 'types+transform' | 'types'; /** * Generate enum definitions? * @default false */ enums?: 'javascript' | 'typescript' | false; /** * Generate types? * @default true */ export?: boolean; /** * Include only types matching regular expression */ include?: string; /** * Use your preferred naming pattern * @default 'preserve' */ name?: 'PascalCase' | 'preserve'; }; /** * Use options or arguments functions * @deprecated * @default true */ useOptions?: boolean; } type UserConfig = ClientConfig; /** * Generate the OpenAPI client. This method will read the OpenAPI specification and based on the * given language it will generate the client, including the typed models, validation schemas, * service layer, etc. * @param userConfig {@link UserConfig} passed to the `createClient()` method */ declare function createClient(userConfig: UserConfig): Promise; /** * Type helper for openapi-ts.config.ts, returns {@link UserConfig} object */ declare function defineConfig(config: UserConfig): UserConfig; export { type UserConfig, createClient, defineConfig };