UNPKG

@kubb/plugin-oas

Version:

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

80 lines (76 loc) 1.99 kB
import { n as getBanner, t as getFooter } from "./getFooter-DVB-hawK.js"; import { camelCase } from "@kubb/core/transformers"; //#region src/generators/createGenerator.ts function createGenerator(generator) { return { type: "core", async operations() { return []; }, async operation() { return []; }, async schema() { return []; }, ...generator }; } //#endregion //#region src/generators/createReactGenerator.ts /**** * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas. * * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array. * * @returns A generator object with async methods for operations, operation, and schema file generation. */ function createReactGenerator(generator) { return { type: "react", Operations() { return null; }, Operation() { return null; }, Schema() { return null; }, ...generator }; } //#endregion //#region src/generators/jsonGenerator.ts const jsonGenerator = createGenerator({ name: "plugin-oas", async schema({ schema, generator }) { const { pluginManager, plugin } = generator.context; return [{ ...pluginManager.getFile({ name: camelCase(schema.name), extname: ".json", mode: "split", pluginKey: plugin.key }), sources: [{ name: camelCase(schema.name), isExportable: false, isIndexable: false, value: JSON.stringify(schema.value) }], banner: getBanner({ oas: generator.context.oas, output: plugin.options.output, config: pluginManager.config }), format: getFooter({ oas: generator.context.oas, output: plugin.options.output }) }]; } }); //#endregion export { createReactGenerator as n, createGenerator as r, jsonGenerator as t }; //# sourceMappingURL=generators-DP42tXgJ.js.map