UNPKG

@kubb/plugin-oas

Version:

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

114 lines (113 loc) 3.53 kB
import { t as __name } from "./chunk--u3MIqq1.js"; import { _ as OperationSchemas, f as OperationGenerator } from "./createGenerator-W6EtzLmf.js"; import { Oas, Operation } from "@kubb/oas"; import { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from "@kubb/core"; import { KubbFile } from "@kubb/fabric-core/types"; import { RootNode } from "@kubb/ast/types"; //#region src/hooks/useOas.d.ts declare function useOas(): Oas; //#endregion //#region src/hooks/useOperationManager.d.ts type FileMeta$1 = FileMetaBase & { pluginKey: Plugin['key']; name: string; group?: { tag?: string; path?: string; }; }; type SchemaNames = { request: string | undefined; parameters: { path: string | undefined; query: string | undefined; header: string | undefined; }; responses: { default?: string; } & Record<number | string, string>; errors: Record<number | string, string>; }; type UseOperationManagerResult = { getName: (operation: Operation, params: { prefix?: string; suffix?: string; pluginKey?: Plugin['key']; type: ResolveNameParams['type']; }) => string; getFile: (operation: Operation, params?: { prefix?: string; suffix?: string; pluginKey?: Plugin['key']; extname?: KubbFile.Extname; group?: { tag?: string; path?: string; }; }) => KubbFile.File<FileMeta$1>; groupSchemasByName: (operation: Operation, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type']; }) => SchemaNames; getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type']; }) => OperationSchemas; getGroup: (operation: Operation) => FileMeta$1['group'] | undefined; }; /** * `useOperationManager` returns helper functions to get the operation file and operation name. */ declare function useOperationManager<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions>(generator: Omit<OperationGenerator<TPluginOptions>, 'build'>): UseOperationManagerResult; //#endregion //#region src/hooks/useRootNode.d.ts /** * Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter. * * Use this hook inside generator components when you want to consume the * format-agnostic AST directly instead of going through `useOas()`. * * Returns `undefined` when no adapter was configured (legacy OAS-only mode). * * @example * ```tsx * function MyComponent() { * const rootNode = useRootNode() * if (!rootNode) return null * return <>{rootNode.schemas.map(s => <Schema key={s.name} node={s} />)}</> * } * ``` */ declare function useRootNode(): RootNode | undefined; //#endregion //#region src/hooks/useSchemaManager.d.ts type FileMeta = FileMetaBase & { pluginKey: Plugin['key']; name: string; group?: { tag?: string; path?: string; }; }; type UseSchemaManagerResult = { getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type']; }) => string; getFile: (name: string, params?: { pluginKey?: Plugin['key']; mode?: KubbFile.Mode; extname?: KubbFile.Extname; group?: { tag?: string; path?: string; }; }) => KubbFile.File<FileMeta>; }; /** * `useSchemaManager` returns helper functions to get the schema file and schema name. */ declare function useSchemaManager(): UseSchemaManagerResult; //#endregion export { type SchemaNames, useOas, useOperationManager, useRootNode, useSchemaManager }; //# sourceMappingURL=hooks.d.ts.map