UNPKG

@kubb/plugin-oas

Version:

OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.

67 lines (58 loc) 2.52 kB
import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1, contentType, OasTypes } from '@kubb/oas'; export { isOptional } from '@kubb/oas'; import { FunctionParamsAST } from '@kubb/core/utils'; import { Params } from '@kubb/react/types'; import { n as OperationSchema } from './OperationGenerator-C7NPZtOM.js'; import { Config, Output } from '@kubb/core'; import '@kubb/core/fs'; import './SchemaMapper-B21ZmWag.js'; declare function getComments(operation: Operation): string[]; declare function getPathParams(operationSchema: OperationSchema | undefined, options?: { typed?: boolean; casing?: 'camelcase'; override?: (data: FunctionParamsAST) => FunctionParamsAST; }): Params; /** * Make it possible to narrow down the schema based on a specific version(3 or 3.1) */ type SchemaResult<TWithRef extends boolean = false> = { schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & { nullable?: boolean; 'x-nullable'?: boolean; }; version: '3.0'; } | { schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & { nullable?: boolean; 'x-nullable'?: boolean; }; version: '3.1'; }; /** * Creates a factory function that generates a versioned OpenAPI schema result. * * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1'). * * @returns A function that takes an optional schema and returns a versioned schema result. */ declare function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef>; type Mode = 'schemas' | 'responses' | 'requestBodies'; type GetSchemasProps = { oas: Oas; contentType?: contentType; includes?: Mode[]; }; declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>; declare function parseFromConfig(config: Config, oasClass?: typeof Oas): Promise<Oas>; type Props$1 = { oas: Oas; output: Output<Oas>; config?: Config; }; declare function getBanner({ output, oas, config }: Props$1): string; type Props = { oas: Oas; output: Output<Oas>; }; declare function getFooter({ output, oas }: Props): string | undefined; export { getBanner, getComments, getFooter, getPathParams, getSchemaFactory, getSchemas, parseFromConfig };