@kubb/swagger-ts 2.6.3 → 2.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -166,7 +166,7 @@ Query.File = function({ mode }) {
166
166
  const file = hooks.useOperationFile();
167
167
  const factoryName = hooks.useOperationName({ type: "type" });
168
168
  const operation = hooks.useOperation();
169
- const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.errors);
169
+ const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.statusCodes);
170
170
  const { source, imports } = builder.build();
171
171
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
172
172
  react.File,
@@ -776,7 +776,7 @@ Mutation.File = function({ mode }) {
776
776
  const file = hooks.useOperationFile();
777
777
  const factoryName = hooks.useOperationName({ type: "type" });
778
778
  const operation = hooks.useOperation();
779
- const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.request).add(schemas.errors);
779
+ const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.request).add(schemas.statusCodes);
780
780
  const { source, imports } = builder.build();
781
781
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
782
782
  react.File,
@@ -804,4 +804,4 @@ exports.definePlugin = definePlugin;
804
804
  exports.pluginKey = pluginKey;
805
805
  exports.pluginName = pluginName;
806
806
  //# sourceMappingURL=out.js.map
807
- //# sourceMappingURL=chunk-WM64J24S.cjs.map
807
+ //# sourceMappingURL=chunk-3QUKTW23.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mutation.tsx","../src/TypeBuilder.ts","../src/TypeGenerator.ts","../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/Oas.tsx","../src/components/Query.tsx"],"names":["transformers","print","factory","File","usePlugin","usePluginManager","useOas","useOperation","useOperationFile","useOperationName","useSchemas","Generator","keywordTypeNodes","Template","pluginKey","Fragment","jsx","jsxs","options","node","path","printCombinedSchema"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,QAAAC,OAAM,aAAAC,YAAW,oBAAAC,yBAAwB;AAClD,SAAS,UAAAC,SAAQ,gBAAAC,eAAc,oBAAAC,mBAAkB,oBAAAC,mBAAkB,cAAAC,mBAAkB;;;ACJrF,OAAOV,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;;;ACH3B,SAAS,aAAAU,kBAAiB;AAC1B,OAAOX,mBAAkB;AACzB,SAAS,qBAAqB;AAC9B,YAAYE,cAAa;AACzB,SAAS,oBAAAU,yBAAwB;AACjC,SAAS,kBAAkB,mBAAmB;;;ACL9C,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,yBAAyB;;;ACLhD,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB,iBAAiB;;;ACDhD,SAAS,MAAM,MAAM,iBAAiB;AACtC,SAAS,eAAe;AACxB,SAAS,cAAc;AAqBnB,mBAEE,KAFF;AANJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,SACE,iCACG;AAAA,oBAAgB,IAAI,MAAM,KAAK,UAAU,KAAK,QAAW,CAAC,CAAC;AAAA,IAC5D,oBAAC,QAAG;AAAA,IACJ,oBAAC,QAAK,MAAM,UAAU,QAAM,MACzB,0BAAgB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AD,WAAA,EACG,kBACH;AAEJ;AAMA,SAAS,OAAO,SAAS,EAAE,KAAK,GAAyB;AACvD,QAAM,EAAE,QAAQ,IAAIX,WAAyB;AAE7C,QAAM,UAAUM,YAAW;AAC3B,QAAM,gBAAgBL,kBAAiB;AACvC,QAAM,MAAMC,QAAO;AACnB,QAAM,OAAOE,kBAAiB;AAC9B,QAAM,cAAcC,kBAAiB,EAAE,MAAM,OAAO,CAAC;AACrD,QAAM,YAAYF,cAAa;AAE/B,QAAM,UAAU,IAAI,YAAY,SAAS,EAAE,KAAK,cAAc,CAAC,EAC5D,IAAI,QAAQ,UAAU,EACtB,IAAI,QAAQ,WAAW,EACvB,IAAI,QAAQ,YAAY,EACxB,IAAI,QAAQ,QAAQ,EACpB,IAAI,QAAQ,OAAO,EACnB,IAAI,QAAQ,WAAW;AAE1B,QAAM,EAAE,QAAQ,QAAQ,IAAI,QAAQ,MAAM;AAE1C,SACE,gBAAAS,KAAAD,WAAA,EACE,0BAAAE;AAAA,IAACd;AAAA,IAAA;AAAA,MACC,UAAU,KAAK;AAAA,MACf,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MAEV;AAAA,iBAAS,eAAe,QAAQ,IAAI,CAAC,MAAM,UAAU;AACpD,iBAAO,gBAAAa,KAACb,MAAK,QAAL,EAAwB,MAAM,KAAK,MAAO,GAAG,QAA5B,KAAkC;AAAA,QAC7D,CAAC;AAAA,QACD,gBAAAc,MAACd,MAAK,QAAL,EACE;AAAA;AAAA,UACAkB,qBAAoB,aAAa,WAAW,OAAO;AAAA,WACtD;AAAA;AAAA;AAAA,EACF,GACF;AAEJ","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Mutation({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nMutation.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.request)\n .add(schemas.statusCodes)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport { OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from './TypeGenerator.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ImportMeta } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {\n build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>> {\n const importMeta: ImportMeta[] = []\n const codes: string[] = []\n\n const generated = this.items\n .filter((operationSchema) => (name ? operationSchema.name === name : true))\n .sort(transformers.nameSorter)\n .map((operationSchema) => {\n const generator = new TypeGenerator(this.options, this.context)\n const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required\n\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n optional: !required && !!operationSchema.name.includes('Params'),\n })\n\n importMeta.push(...generator.imports)\n\n return {\n import: {\n refs: generator.refs,\n name: operationSchema.name,\n },\n sources,\n }\n })\n .sort(refsSorter)\n\n generated.forEach((item) => {\n codes.push(print(item.sources))\n })\n\n const imports: KubbFile.Import[] = importMeta.map((item) => {\n return {\n name: [item.ref.propertyName],\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n }\n })\n\n return {\n imports,\n source: transformers.combineCodes(codes),\n }\n }\n}\n","import { Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { keywordTypeNodes } from '@kubb/parser/factory'\nimport { getSchemaFactory, isReference } from '@kubb/swagger/utils'\n\nimport { pluginKey } from './plugin.ts'\n\nimport type { PluginManager } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { ImportMeta, Refs } from '@kubb/swagger'\nimport type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1 } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Context = {\n oas: Oas\n pluginManager: PluginManager\n}\n\nexport class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], Context> {\n refs: Refs = {}\n imports: ImportMeta[] = []\n\n extraNodes: ts.Node[] = []\n\n aliases: ts.TypeAliasDeclaration[] = []\n\n // Keep track of already used type aliases\n #usedAliasNames: Record<string, number> = {}\n\n build({\n schema,\n optional,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OasTypes.SchemaObject\n baseName: string\n description?: string\n optional?: boolean\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n let type = this.getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n if (optional) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: 'type' }),\n type: keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type, nonNullable: true }) : type,\n })\n\n if (description) {\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [`@description ${transformers.trim(description)}`],\n }),\n )\n } else {\n nodes.push(node)\n }\n\n // filter out if the export name is the same as one that we already defined in extraNodes(see enum)\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !this.extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return [...this.extraNodes, ...filterdNodes]\n }\n\n /**\n * Creates a type node from a given schema.\n * Delegates to getBaseTypeFromSchema internally and\n * optionally adds a union with null.\n */\n getTypeFromSchema(schema?: OasTypes.SchemaObject, name?: string): ts.TypeNode | null {\n const type = this.#getBaseTypeFromSchema(schema, name)\n\n if (!type) {\n return null\n }\n\n if (schema && !schema.nullable) {\n return type\n }\n\n return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n /**\n * Recursively creates a type literal with the given props.\n */\n #getTypeFromProperties(baseSchema?: OasTypes.SchemaObject, baseName?: string): ts.TypeNode | null {\n const { optionalType } = this.options\n const properties = baseSchema?.properties || {}\n const required = baseSchema?.required\n const additionalProperties = baseSchema?.additionalProperties\n\n const members: Array<ts.TypeElement | null> = Object.keys(properties).map((name) => {\n const schema = properties[name] as OasTypes.SchemaObject\n\n const isRequired = Array.isArray(required) ? required.includes(name) : !!required\n let type = this.getTypeFromSchema(schema, this.context.pluginManager.resolveName({ name: `${baseName || ''} ${name}`, pluginKey, type: 'type' }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType as string) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n schema.description ? `@description ${schema.description}` : undefined,\n schema.type ? `@type ${schema.type?.toString()}${isRequired ? '' : ' | undefined'} ${schema.format || ''}` : undefined,\n schema.example ? `@example ${schema.example as string}` : undefined,\n schema.deprecated ? `@deprecated` : undefined,\n schema.default !== undefined && typeof schema.default === 'string' ? `@default '${schema.default}'` : undefined,\n schema.default !== undefined && typeof schema.default !== 'string' ? `@default ${schema.default as string}` : undefined,\n ].filter(Boolean),\n })\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? this.#unknownReturn : this.getTypeFromSchema(additionalProperties as OasTypes.SchemaObject)\n\n if (type) {\n members.push(factory.createIndexSignature(type))\n }\n }\n return factory.createTypeLiteralNode(members.filter(Boolean))\n }\n\n /**\n * Create a type alias for the schema referenced by the given ReferenceObject\n */\n #getRefAlias(obj: OpenAPIV3.ReferenceObject, _baseName?: string) {\n const { $ref } = obj\n let ref = this.refs[$ref]\n\n if (ref) {\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n const originalName = getUniqueName($ref.replace(/.+\\//, ''), this.#usedAliasNames)\n const propertyName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'type' })\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'file' })\n const path = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey })\n\n this.imports.push({\n ref,\n path: path || '',\n isTypeOnly: true,\n })\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n #getParsedSchema(schema?: OasTypes.SchemaObject) {\n const parsedSchema = getSchemaFactory(this.context.oas)(schema)\n return parsedSchema\n }\n\n /**\n * This is the very core of the OpenAPI to TS conversion - it takes a\n * schema and returns the appropriate type.\n */\n #getBaseTypeFromSchema(\n _schema: OasTypes.SchemaObject | undefined,\n baseName?: string,\n ): ts.TypeNode | null {\n const { schema, version } = this.#getParsedSchema(_schema)\n\n if (!schema) {\n return this.#unknownReturn\n }\n\n if (isReference(schema)) {\n return this.#getRefAlias(schema, baseName)\n }\n\n if (schema.oneOf) {\n // union\n const schemaWithoutOneOf = { ...schema, oneOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.oneOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n\n if (schema.anyOf) {\n const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.anyOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAnyOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n if (schema.allOf) {\n // intersection/add\n const schemaWithoutAllOf = { ...schema, allOf: undefined } as OasTypes.SchemaObject\n\n const and = factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes: schema.allOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean),\n })\n }\n\n return and\n }\n\n /**\n * Enum will be defined outside the baseType(hints the baseName check)\n */\n if (schema.enum && baseName) {\n const enumName = getUniqueName(baseName, this.options.usedEnumNames)\n\n let enums: [key: string, value: string | number][] = [...new Set(schema.enum)].map((key) => [key, key])\n\n const extensionEnums: Array<typeof enums> = ['x-enumNames', 'x-enum-varnames']\n .filter(extensionKey => extensionKey in schema)\n .map((extensionKey) =>\n [...new Set(schema[extensionKey as keyof typeof schema] as string[])].map((key, index) => [key, schema.enum?.[index] as string] as const)\n )\n\n if (extensionEnums.length > 0 && extensionEnums[0]) {\n enums = extensionEnums[0]\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: transformers.camelCase(enumName),\n typeName: this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }), undefined)\n }\n\n if (schema.enum) {\n return factory.createUnionDeclaration({\n nodes: schema.enum.map((name) => {\n return factory.createLiteralTypeNode(typeof name === 'number' ? factory.createNumericLiteral(name) : factory.createStringLiteral(`${name}`))\n }) as unknown as Array<ts.TypeNode>,\n })\n }\n\n if ('items' in schema) {\n // items -> array\n const node = this.getTypeFromSchema(schema.items as OasTypes.SchemaObject, baseName)\n if (node) {\n return factory.createArrayTypeNode(node)\n }\n }\n\n /**\n * OpenAPI 3.1\n * @link https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation\n */\n\n if ('prefixItems' in schema) {\n const prefixItems = schema.prefixItems as OasTypes.SchemaObject[]\n\n return factory.createTupleDeclaration({\n nodes: prefixItems.map((item) => {\n // no baseType so we can fall back on an union when using enum\n return this.getTypeFromSchema(item, undefined)\n }) as Array<ts.TypeNode>,\n })\n }\n\n if (schema.properties || schema.additionalProperties) {\n // properties -> literal type\n return this.#getTypeFromProperties(schema, baseName)\n }\n\n /**\n * validate \"const\" property as defined in JSON-Schema-Validation\n *\n * https://json-schema.org/draft/2020-12/json-schema-validation#name-const\n *\n * > 6.1.3. const\n * > The value of this keyword MAY be of any type, including null.\n * > Use of this keyword is functionally equivalent to an \"enum\" (Section 6.1.2) with a single value.\n * > An instance validates successfully against this keyword if its value is equal to the value of the keyword.\n */\n if (version === '3.1' && 'const' in schema) {\n // const keyword takes precendence over the actual type.\n if (schema['const']) {\n if (typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n } else if (typeof schema['const'] === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(schema['const']))\n }\n } else {\n return keywordTypeNodes.null\n }\n }\n\n if (schema.type) {\n if (Array.isArray(schema.type)) {\n // TODO remove hardcoded first type, second nullable\n // OPENAPI v3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n const [type, nullable] = schema.type as Array<OpenAPIV3_1.NonArraySchemaObjectType>\n\n return factory.createUnionDeclaration({\n nodes: [\n this.getTypeFromSchema(\n {\n ...schema,\n type,\n },\n baseName,\n ),\n nullable ? factory.createLiteralTypeNode(factory.createNull()) : undefined,\n ].filter(Boolean),\n })\n }\n\n if (this.options.dateType === 'date' && ['date', 'date-time'].some((item) => item === schema.format)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Date'))\n }\n\n // string, boolean, null, number\n if (schema.type in factory.keywordTypeNodes) {\n return factory.keywordTypeNodes[schema.type as keyof typeof factory.keywordTypeNodes]\n }\n }\n\n if (schema.format === 'binary') {\n return factory.createTypeReferenceNode('Blob', [])\n }\n\n return this.#unknownReturn\n }\n\n get #unknownReturn() {\n if (this.options.unknownType === 'any') {\n return factory.keywordTypeNodes.any\n }\n\n return factory.keywordTypeNodes.unknown\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { TypeBuilder } from './TypeBuilder.ts'\n\nimport type { KubbFile, Plugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = [pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = { path: 'types' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n transformers = {},\n oasType = false,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginName,\n options: {\n transformers,\n dateType,\n enumType,\n optionalType,\n oasType,\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n unknownType,\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, directory, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'file') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n\n const schemas = await swaggerPlugin.api.getSchemas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const builder = new TypeBuilder(this.plugin.options, { oas, pluginManager: this.pluginManager })\n\n builder.add(\n Object.entries(schemas).map(([name, schema]: [string, OasTypes.SchemaObject]) => ({ name, schema })),\n )\n\n if (mode === 'directory') {\n const mapFolderSchema = async ([name]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${this.resolveName({ name, pluginKey: this.plugin.key, type: 'file' })}.ts` as const\n const resolvedPath = this.resolvePath({ baseName, pluginKey: this.plugin.key })\n const { source, imports } = builder.build(name)\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName,\n source,\n imports: imports.map(item => ({ ...item, root: resolvedPath })),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapFolderSchema)\n\n await Promise.all(promises)\n }\n\n if (mode === 'file') {\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n const { source } = builder.build()\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output.path as KubbFile.BaseName,\n source,\n imports: [],\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const operationGenerator = new OperationGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n })\n },\n }\n})\n","import { createRoot } from '@kubb/react'\nimport { OperationGenerator as Generator } from '@kubb/swagger'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Oas } from './components/Oas.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult, OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async all(): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n if (!plugin.options.oasType) {\n return null\n }\n\n const root = createRoot<AppContextProps>({ logger: pluginManager.logger })\n root.render(\n <Oas.File name=\"oas\" typeName=\"Oas\" />,\n { meta: { oas, pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Query.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Mutation.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n}\n","import { File, Type, usePlugin } from '@kubb/react'\nimport { useFile } from '@kubb/react'\nimport { useOas } from '@kubb/swagger/hooks'\n\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n api: OasTypes.OASDocument\n}\n\nfunction Template({\n name,\n typeName,\n api,\n}: TemplateProps): ReactNode {\n return (\n <>\n {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}\n <br />\n <Type name={typeName} export>\n {`Infer<typeof ${name}>`}\n </Type>\n </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Oas({\n name,\n typeName,\n Template = defaultTemplates.default,\n}: Props): ReactNode {\n const oas = useOas()\n\n return <Template name={name} typeName={typeName} api={oas.api} />\n}\n\ntype FileProps = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nOas.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useFile({ name, pluginKey })\n\n const Template = templates.default\n\n return (\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n <File.Import name={['Infer']} path=\"@kubb/swagger-ts/oas\" isTypeOnly />\n <File.Source>\n <Oas Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n )\n}\n\nOas.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Query({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nQuery.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.statusCodes)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n"]}
@@ -141,7 +141,7 @@ Query.File = function({ mode }) {
141
141
  const file = useOperationFile();
142
142
  const factoryName = useOperationName({ type: "type" });
143
143
  const operation = useOperation();
144
- const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.errors);
144
+ const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.statusCodes);
145
145
  const { source, imports } = builder.build();
146
146
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
147
147
  File,
@@ -751,7 +751,7 @@ Mutation.File = function({ mode }) {
751
751
  const file = useOperationFile();
752
752
  const factoryName = useOperationName({ type: "type" });
753
753
  const operation = useOperation();
754
- const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.request).add(schemas.errors);
754
+ const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.request).add(schemas.statusCodes);
755
755
  const { source, imports } = builder.build();
756
756
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
757
757
  File,
@@ -774,4 +774,4 @@ Mutation.File = function({ mode }) {
774
774
 
775
775
  export { Mutation, Oas, Query, definePlugin, pluginKey, pluginName };
776
776
  //# sourceMappingURL=out.js.map
777
- //# sourceMappingURL=chunk-3K3RRBUO.js.map
777
+ //# sourceMappingURL=chunk-UUY4IHAG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mutation.tsx","../src/TypeBuilder.ts","../src/TypeGenerator.ts","../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/Oas.tsx","../src/components/Query.tsx"],"names":["transformers","print","factory","File","usePlugin","usePluginManager","useOas","useOperation","useOperationFile","useOperationName","useSchemas","Generator","keywordTypeNodes","Template","pluginKey","Fragment","jsx","jsxs","options","node","path","printCombinedSchema"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,QAAAC,OAAM,aAAAC,YAAW,oBAAAC,yBAAwB;AAClD,SAAS,UAAAC,SAAQ,gBAAAC,eAAc,oBAAAC,mBAAkB,oBAAAC,mBAAkB,cAAAC,mBAAkB;;;ACJrF,OAAOV,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;;;ACH3B,SAAS,aAAAU,kBAAiB;AAC1B,OAAOX,mBAAkB;AACzB,SAAS,qBAAqB;AAC9B,YAAYE,cAAa;AACzB,SAAS,oBAAAU,yBAAwB;AACjC,SAAS,kBAAkB,mBAAmB;;;ACL9C,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,yBAAyB;;;ACLhD,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB,iBAAiB;;;ACDhD,SAAS,MAAM,MAAM,iBAAiB;AACtC,SAAS,eAAe;AACxB,SAAS,cAAc;AAqBnB,mBAEE,KAFF;AANJ,SAAS,SAAS;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ers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Mutation({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nMutation.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.request)\n .add(schemas.statusCodes)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport { OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from './TypeGenerator.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ImportMeta } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {\n build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>> {\n const importMeta: ImportMeta[] = []\n const codes: string[] = []\n\n const generated = this.items\n .filter((operationSchema) => (name ? operationSchema.name === name : true))\n .sort(transformers.nameSorter)\n .map((operationSchema) => {\n const generator = new TypeGenerator(this.options, this.context)\n const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required\n\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n optional: !required && !!operationSchema.name.includes('Params'),\n })\n\n importMeta.push(...generator.imports)\n\n return {\n import: {\n refs: generator.refs,\n name: operationSchema.name,\n },\n sources,\n }\n })\n .sort(refsSorter)\n\n generated.forEach((item) => {\n codes.push(print(item.sources))\n })\n\n const imports: KubbFile.Import[] = importMeta.map((item) => {\n return {\n name: [item.ref.propertyName],\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n }\n })\n\n return {\n imports,\n source: transformers.combineCodes(codes),\n }\n }\n}\n","import { Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { keywordTypeNodes } from '@kubb/parser/factory'\nimport { getSchemaFactory, isReference } from '@kubb/swagger/utils'\n\nimport { pluginKey } from './plugin.ts'\n\nimport type { PluginManager } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { ImportMeta, Refs } from '@kubb/swagger'\nimport type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1 } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Context = {\n oas: Oas\n pluginManager: PluginManager\n}\n\nexport class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], Context> {\n refs: Refs = {}\n imports: ImportMeta[] = []\n\n extraNodes: ts.Node[] = []\n\n aliases: ts.TypeAliasDeclaration[] = []\n\n // Keep track of already used type aliases\n #usedAliasNames: Record<string, number> = {}\n\n build({\n schema,\n optional,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OasTypes.SchemaObject\n baseName: string\n description?: string\n optional?: boolean\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n let type = this.getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n if (optional) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: 'type' }),\n type: keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type, nonNullable: true }) : type,\n })\n\n if (description) {\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [`@description ${transformers.trim(description)}`],\n }),\n )\n } else {\n nodes.push(node)\n }\n\n // filter out if the export name is the same as one that we already defined in extraNodes(see enum)\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !this.extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return [...this.extraNodes, ...filterdNodes]\n }\n\n /**\n * Creates a type node from a given schema.\n * Delegates to getBaseTypeFromSchema internally and\n * optionally adds a union with null.\n */\n getTypeFromSchema(schema?: OasTypes.SchemaObject, name?: string): ts.TypeNode | null {\n const type = this.#getBaseTypeFromSchema(schema, name)\n\n if (!type) {\n return null\n }\n\n if (schema && !schema.nullable) {\n return type\n }\n\n return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n /**\n * Recursively creates a type literal with the given props.\n */\n #getTypeFromProperties(baseSchema?: OasTypes.SchemaObject, baseName?: string): ts.TypeNode | null {\n const { optionalType } = this.options\n const properties = baseSchema?.properties || {}\n const required = baseSchema?.required\n const additionalProperties = baseSchema?.additionalProperties\n\n const members: Array<ts.TypeElement | null> = Object.keys(properties).map((name) => {\n const schema = properties[name] as OasTypes.SchemaObject\n\n const isRequired = Array.isArray(required) ? required.includes(name) : !!required\n let type = this.getTypeFromSchema(schema, this.context.pluginManager.resolveName({ name: `${baseName || ''} ${name}`, pluginKey, type: 'type' }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType as string) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n schema.description ? `@description ${schema.description}` : undefined,\n schema.type ? `@type ${schema.type?.toString()}${isRequired ? '' : ' | undefined'} ${schema.format || ''}` : undefined,\n schema.example ? `@example ${schema.example as string}` : undefined,\n schema.deprecated ? `@deprecated` : undefined,\n schema.default !== undefined && typeof schema.default === 'string' ? `@default '${schema.default}'` : undefined,\n schema.default !== undefined && typeof schema.default !== 'string' ? `@default ${schema.default as string}` : undefined,\n ].filter(Boolean),\n })\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? this.#unknownReturn : this.getTypeFromSchema(additionalProperties as OasTypes.SchemaObject)\n\n if (type) {\n members.push(factory.createIndexSignature(type))\n }\n }\n return factory.createTypeLiteralNode(members.filter(Boolean))\n }\n\n /**\n * Create a type alias for the schema referenced by the given ReferenceObject\n */\n #getRefAlias(obj: OpenAPIV3.ReferenceObject, _baseName?: string) {\n const { $ref } = obj\n let ref = this.refs[$ref]\n\n if (ref) {\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n const originalName = getUniqueName($ref.replace(/.+\\//, ''), this.#usedAliasNames)\n const propertyName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'type' })\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'file' })\n const path = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey })\n\n this.imports.push({\n ref,\n path: path || '',\n isTypeOnly: true,\n })\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n #getParsedSchema(schema?: OasTypes.SchemaObject) {\n const parsedSchema = getSchemaFactory(this.context.oas)(schema)\n return parsedSchema\n }\n\n /**\n * This is the very core of the OpenAPI to TS conversion - it takes a\n * schema and returns the appropriate type.\n */\n #getBaseTypeFromSchema(\n _schema: OasTypes.SchemaObject | undefined,\n baseName?: string,\n ): ts.TypeNode | null {\n const { schema, version } = this.#getParsedSchema(_schema)\n\n if (!schema) {\n return this.#unknownReturn\n }\n\n if (isReference(schema)) {\n return this.#getRefAlias(schema, baseName)\n }\n\n if (schema.oneOf) {\n // union\n const schemaWithoutOneOf = { ...schema, oneOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.oneOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n\n if (schema.anyOf) {\n const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.anyOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAnyOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n if (schema.allOf) {\n // intersection/add\n const schemaWithoutAllOf = { ...schema, allOf: undefined } as OasTypes.SchemaObject\n\n const and = factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes: schema.allOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean),\n })\n }\n\n return and\n }\n\n /**\n * Enum will be defined outside the baseType(hints the baseName check)\n */\n if (schema.enum && baseName) {\n const enumName = getUniqueName(baseName, this.options.usedEnumNames)\n\n let enums: [key: string, value: string | number][] = [...new Set(schema.enum)].map((key) => [key, key])\n\n const extensionEnums: Array<typeof enums> = ['x-enumNames', 'x-enum-varnames']\n .filter(extensionKey => extensionKey in schema)\n .map((extensionKey) =>\n [...new Set(schema[extensionKey as keyof typeof schema] as string[])].map((key, index) => [key, schema.enum?.[index] as string] as const)\n )\n\n if (extensionEnums.length > 0 && extensionEnums[0]) {\n enums = extensionEnums[0]\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: transformers.camelCase(enumName),\n typeName: this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }), undefined)\n }\n\n if (schema.enum) {\n return factory.createUnionDeclaration({\n nodes: schema.enum.map((name) => {\n return factory.createLiteralTypeNode(typeof name === 'number' ? factory.createNumericLiteral(name) : factory.createStringLiteral(`${name}`))\n }) as unknown as Array<ts.TypeNode>,\n })\n }\n\n if ('items' in schema) {\n // items -> array\n const node = this.getTypeFromSchema(schema.items as OasTypes.SchemaObject, baseName)\n if (node) {\n return factory.createArrayTypeNode(node)\n }\n }\n\n /**\n * OpenAPI 3.1\n * @link https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation\n */\n\n if ('prefixItems' in schema) {\n const prefixItems = schema.prefixItems as OasTypes.SchemaObject[]\n\n return factory.createTupleDeclaration({\n nodes: prefixItems.map((item) => {\n // no baseType so we can fall back on an union when using enum\n return this.getTypeFromSchema(item, undefined)\n }) as Array<ts.TypeNode>,\n })\n }\n\n if (schema.properties || schema.additionalProperties) {\n // properties -> literal type\n return this.#getTypeFromProperties(schema, baseName)\n }\n\n /**\n * validate \"const\" property as defined in JSON-Schema-Validation\n *\n * https://json-schema.org/draft/2020-12/json-schema-validation#name-const\n *\n * > 6.1.3. const\n * > The value of this keyword MAY be of any type, including null.\n * > Use of this keyword is functionally equivalent to an \"enum\" (Section 6.1.2) with a single value.\n * > An instance validates successfully against this keyword if its value is equal to the value of the keyword.\n */\n if (version === '3.1' && 'const' in schema) {\n // const keyword takes precendence over the actual type.\n if (schema['const']) {\n if (typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n } else if (typeof schema['const'] === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(schema['const']))\n }\n } else {\n return keywordTypeNodes.null\n }\n }\n\n if (schema.type) {\n if (Array.isArray(schema.type)) {\n // TODO remove hardcoded first type, second nullable\n // OPENAPI v3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n const [type, nullable] = schema.type as Array<OpenAPIV3_1.NonArraySchemaObjectType>\n\n return factory.createUnionDeclaration({\n nodes: [\n this.getTypeFromSchema(\n {\n ...schema,\n type,\n },\n baseName,\n ),\n nullable ? factory.createLiteralTypeNode(factory.createNull()) : undefined,\n ].filter(Boolean),\n })\n }\n\n if (this.options.dateType === 'date' && ['date', 'date-time'].some((item) => item === schema.format)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Date'))\n }\n\n // string, boolean, null, number\n if (schema.type in factory.keywordTypeNodes) {\n return factory.keywordTypeNodes[schema.type as keyof typeof factory.keywordTypeNodes]\n }\n }\n\n if (schema.format === 'binary') {\n return factory.createTypeReferenceNode('Blob', [])\n }\n\n return this.#unknownReturn\n }\n\n get #unknownReturn() {\n if (this.options.unknownType === 'any') {\n return factory.keywordTypeNodes.any\n }\n\n return factory.keywordTypeNodes.unknown\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { TypeBuilder } from './TypeBuilder.ts'\n\nimport type { KubbFile, Plugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = [pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = { path: 'types' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n transformers = {},\n oasType = false,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginName,\n options: {\n transformers,\n dateType,\n enumType,\n optionalType,\n oasType,\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n unknownType,\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, directory, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'file') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n\n const schemas = await swaggerPlugin.api.getSchemas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const builder = new TypeBuilder(this.plugin.options, { oas, pluginManager: this.pluginManager })\n\n builder.add(\n Object.entries(schemas).map(([name, schema]: [string, OasTypes.SchemaObject]) => ({ name, schema })),\n )\n\n if (mode === 'directory') {\n const mapFolderSchema = async ([name]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${this.resolveName({ name, pluginKey: this.plugin.key, type: 'file' })}.ts` as const\n const resolvedPath = this.resolvePath({ baseName, pluginKey: this.plugin.key })\n const { source, imports } = builder.build(name)\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName,\n source,\n imports: imports.map(item => ({ ...item, root: resolvedPath })),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapFolderSchema)\n\n await Promise.all(promises)\n }\n\n if (mode === 'file') {\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n const { source } = builder.build()\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output.path as KubbFile.BaseName,\n source,\n imports: [],\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const operationGenerator = new OperationGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n })\n },\n }\n})\n","import { createRoot } from '@kubb/react'\nimport { OperationGenerator as Generator } from '@kubb/swagger'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Oas } from './components/Oas.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult, OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async all(): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n if (!plugin.options.oasType) {\n return null\n }\n\n const root = createRoot<AppContextProps>({ logger: pluginManager.logger })\n root.render(\n <Oas.File name=\"oas\" typeName=\"Oas\" />,\n { meta: { oas, pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Query.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Mutation.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n}\n","import { File, Type, usePlugin } from '@kubb/react'\nimport { useFile } from '@kubb/react'\nimport { useOas } from '@kubb/swagger/hooks'\n\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n api: OasTypes.OASDocument\n}\n\nfunction Template({\n name,\n typeName,\n api,\n}: TemplateProps): ReactNode {\n return (\n <>\n {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}\n <br />\n <Type name={typeName} export>\n {`Infer<typeof ${name}>`}\n </Type>\n </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Oas({\n name,\n typeName,\n Template = defaultTemplates.default,\n}: Props): ReactNode {\n const oas = useOas()\n\n return <Template name={name} typeName={typeName} api={oas.api} />\n}\n\ntype FileProps = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nOas.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useFile({ name, pluginKey })\n\n const Template = templates.default\n\n return (\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n <File.Import name={['Infer']} path=\"@kubb/swagger-ts/oas\" isTypeOnly />\n <File.Source>\n <Oas Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n )\n}\n\nOas.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Query({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nQuery.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.statusCodes)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n"]}
@@ -1,20 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var chunkWM64J24S_cjs = require('./chunk-WM64J24S.cjs');
3
+ var chunk3QUKTW23_cjs = require('./chunk-3QUKTW23.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Mutation", {
8
8
  enumerable: true,
9
- get: function () { return chunkWM64J24S_cjs.Mutation; }
9
+ get: function () { return chunk3QUKTW23_cjs.Mutation; }
10
10
  });
11
11
  Object.defineProperty(exports, "Oas", {
12
12
  enumerable: true,
13
- get: function () { return chunkWM64J24S_cjs.Oas; }
13
+ get: function () { return chunk3QUKTW23_cjs.Oas; }
14
14
  });
15
15
  Object.defineProperty(exports, "Query", {
16
16
  enumerable: true,
17
- get: function () { return chunkWM64J24S_cjs.Query; }
17
+ get: function () { return chunk3QUKTW23_cjs.Query; }
18
18
  });
19
19
  //# sourceMappingURL=out.js.map
20
20
  //# sourceMappingURL=components.cjs.map
@@ -1,3 +1,3 @@
1
- export { Mutation, Oas, Query } from './chunk-3K3RRBUO.js';
1
+ export { Mutation, Oas, Query } from './chunk-UUY4IHAG.js';
2
2
  //# sourceMappingURL=out.js.map
3
3
  //# sourceMappingURL=components.js.map
package/dist/index.cjs CHANGED
@@ -2,25 +2,25 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var chunkWM64J24S_cjs = require('./chunk-WM64J24S.cjs');
5
+ var chunk3QUKTW23_cjs = require('./chunk-3QUKTW23.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "default", {
10
10
  enumerable: true,
11
- get: function () { return chunkWM64J24S_cjs.definePlugin; }
11
+ get: function () { return chunk3QUKTW23_cjs.definePlugin; }
12
12
  });
13
13
  Object.defineProperty(exports, "definePlugin", {
14
14
  enumerable: true,
15
- get: function () { return chunkWM64J24S_cjs.definePlugin; }
15
+ get: function () { return chunk3QUKTW23_cjs.definePlugin; }
16
16
  });
17
17
  Object.defineProperty(exports, "pluginKey", {
18
18
  enumerable: true,
19
- get: function () { return chunkWM64J24S_cjs.pluginKey; }
19
+ get: function () { return chunk3QUKTW23_cjs.pluginKey; }
20
20
  });
21
21
  Object.defineProperty(exports, "pluginName", {
22
22
  enumerable: true,
23
- get: function () { return chunkWM64J24S_cjs.pluginName; }
23
+ get: function () { return chunk3QUKTW23_cjs.pluginName; }
24
24
  });
25
25
  //# sourceMappingURL=out.js.map
26
26
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { definePlugin as default, definePlugin, pluginKey, pluginName } from './chunk-3K3RRBUO.js';
1
+ export { definePlugin as default, definePlugin, pluginKey, pluginName } from './chunk-UUY4IHAG.js';
2
2
  //# sourceMappingURL=out.js.map
3
3
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/swagger-ts",
3
- "version": "2.6.3",
3
+ "version": "2.6.4",
4
4
  "description": "Generator swagger-ts",
5
5
  "keywords": [
6
6
  "typescript",
@@ -49,15 +49,15 @@
49
49
  "hotscript": "^1.0.13",
50
50
  "json-schema-to-ts": "^3.0.0",
51
51
  "ts-toolbelt": "^9.6.0",
52
- "@kubb/core": "2.6.3",
53
- "@kubb/parser": "2.6.3",
54
- "@kubb/react": "2.6.3",
55
- "@kubb/swagger": "2.6.3",
56
- "@kubb/types": "2.6.3"
52
+ "@kubb/core": "2.6.4",
53
+ "@kubb/parser": "2.6.4",
54
+ "@kubb/react": "2.6.4",
55
+ "@kubb/swagger": "2.6.4",
56
+ "@kubb/types": "2.6.4"
57
57
  },
58
58
  "devDependencies": {
59
- "@types/react": "^18.2.57",
60
- "eslint": "^8.56.0",
59
+ "@types/react": "^18.2.58",
60
+ "eslint": "^8.57.0",
61
61
  "expect-type": "^0.17.3",
62
62
  "react": "^18.2.0",
63
63
  "tsup": "^8.0.2",
@@ -66,7 +66,7 @@
66
66
  "@kubb/tsup-config": "1.1.8"
67
67
  },
68
68
  "peerDependencies": {
69
- "@kubb/react": "2.6.3"
69
+ "@kubb/react": "2.6.4"
70
70
  },
71
71
  "packageManager": "pnpm@8.3.0",
72
72
  "engines": {
@@ -118,7 +118,7 @@ Mutation.File = function({ mode }: FileProps): ReactNode {
118
118
  .add(schemas.headerParams)
119
119
  .add(schemas.response)
120
120
  .add(schemas.request)
121
- .add(schemas.errors)
121
+ .add(schemas.statusCodes)
122
122
 
123
123
  const { source, imports } = builder.build()
124
124
 
@@ -118,7 +118,7 @@ Query.File = function({ mode }: FileProps): ReactNode {
118
118
  .add(schemas.queryParams)
119
119
  .add(schemas.headerParams)
120
120
  .add(schemas.response)
121
- .add(schemas.errors)
121
+ .add(schemas.statusCodes)
122
122
 
123
123
  const { source, imports } = builder.build()
124
124
 
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Mutation.tsx","../src/TypeBuilder.ts","../src/TypeGenerator.ts","../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/Oas.tsx","../src/components/Query.tsx"],"names":["transformers","print","factory","File","usePlugin","usePluginManager","useOas","useOperation","useOperationFile","useOperationName","useSchemas","Generator","keywordTypeNodes","Template","pluginKey","Fragment","jsx","jsxs","options","node","path","printCombinedSchema"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,QAAAC,OAAM,aAAAC,YAAW,oBAAAC,yBAAwB;AAClD,SAAS,UAAAC,SAAQ,gBAAAC,eAAc,oBAAAC,mBAAkB,oBAAAC,mBAAkB,cAAAC,mBAAkB;;;ACJrF,OAAOV,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;;;ACH3B,SAAS,aAAAU,kBAAiB;AAC1B,OAAOX,mBAAkB;AACzB,SAAS,qBAAqB;AAC9B,YAAYE,cAAa;AACzB,SAAS,oBAAAU,yBAAwB;AACjC,SAAS,kBAAkB,mBAAmB;;;ACL9C,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,yBAAyB;;;ACLhD,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB,iBAAiB;;;ACDhD,SAAS,MAAM,MAAM,iBAAiB;AACtC,SAAS,eAAe;AACxB,SAAS,cAAc;AAqBnB,mBAEE,KAFF;AANJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,SACE,iCACG;AAAA,oBAAgB,IAAI,MAAM,KAAK,UAAU,KAAK,QAAW,CAAC,CAAC;AAAA,IAC5D,oBAAC,QAAG;AAAA,IACJ,oBAAC,QAAK,MAAM,UAAU,QAAM,MACzB,0BAAgB,IAAI,KACvB;AAAA,KACF;AAEJ;AAEA,IAAM,mBAAmB,EAAE,SAAS,SAAS;AAWtC,SAAS,IAAI;AA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Q,IAAIX,WAAyB;AAE7C,QAAM,UAAUM,YAAW;AAC3B,QAAM,gBAAgBL,kBAAiB;AACvC,QAAM,MAAMC,QAAO;AACnB,QAAM,OAAOE,kBAAiB;AAC9B,QAAM,cAAcC,kBAAiB,EAAE,MAAM,OAAO,CAAC;AACrD,QAAM,YAAYF,cAAa;AAE/B,QAAM,UAAU,IAAI,YAAY,SAAS,EAAE,KAAK,cAAc,CAAC,EAC5D,IAAI,QAAQ,UAAU,EACtB,IAAI,QAAQ,WAAW,EACvB,IAAI,QAAQ,YAAY,EACxB,IAAI,QAAQ,QAAQ,EACpB,IAAI,QAAQ,OAAO,EACnB,IAAI,QAAQ,MAAM;AAErB,QAAM,EAAE,QAAQ,QAAQ,IAAI,QAAQ,MAAM;AAE1C,SACE,gBAAAS,KAAAD,WAAA,EACE,0BAAAE;AAAA,IAACd;AAAA,IAAA;AAAA,MACC,UAAU,KAAK;AAAA,MACf,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MAEV;AAAA,iBAAS,eAAe,QAAQ,IAAI,CAAC,MAAM,UAAU;AACpD,iBAAO,gBAAAa,KAACb,MAAK,QAAL,EAAwB,MAAM,KAAK,MAAO,GAAG,QAA5B,KAAkC;AAAA,QAC7D,CAAC;AAAA,QACD,gBAAAc,MAACd,MAAK,QAAL,EACE;AAAA;AAAA,UACAkB,qBAAoB,aAAa,WAAW,OAAO;AAAA,WACtD;AAAA;AAAA;AAAA,EACF,GACF;AAEJ","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Mutation({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nMutation.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.request)\n .add(schemas.errors)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport { OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from './TypeGenerator.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ImportMeta } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {\n build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>> {\n const importMeta: ImportMeta[] = []\n const codes: string[] = []\n\n const generated = this.items\n .filter((operationSchema) => (name ? operationSchema.name === name : true))\n .sort(transformers.nameSorter)\n .map((operationSchema) => {\n const generator = new TypeGenerator(this.options, this.context)\n const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required\n\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n optional: !required && !!operationSchema.name.includes('Params'),\n })\n\n importMeta.push(...generator.imports)\n\n return {\n import: {\n refs: generator.refs,\n name: operationSchema.name,\n },\n sources,\n }\n })\n .sort(refsSorter)\n\n generated.forEach((item) => {\n codes.push(print(item.sources))\n })\n\n const imports: KubbFile.Import[] = importMeta.map((item) => {\n return {\n name: [item.ref.propertyName],\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n }\n })\n\n return {\n imports,\n source: transformers.combineCodes(codes),\n }\n }\n}\n","import { Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { keywordTypeNodes } from '@kubb/parser/factory'\nimport { getSchemaFactory, isReference } from '@kubb/swagger/utils'\n\nimport { pluginKey } from './plugin.ts'\n\nimport type { PluginManager } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { ImportMeta, Refs } from '@kubb/swagger'\nimport type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1 } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Context = {\n oas: Oas\n pluginManager: PluginManager\n}\n\nexport class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], Context> {\n refs: Refs = {}\n imports: ImportMeta[] = []\n\n extraNodes: ts.Node[] = []\n\n aliases: ts.TypeAliasDeclaration[] = []\n\n // Keep track of already used type aliases\n #usedAliasNames: Record<string, number> = {}\n\n build({\n schema,\n optional,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OasTypes.SchemaObject\n baseName: string\n description?: string\n optional?: boolean\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n let type = this.getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n if (optional) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: 'type' }),\n type: keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type, nonNullable: true }) : type,\n })\n\n if (description) {\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [`@description ${transformers.trim(description)}`],\n }),\n )\n } else {\n nodes.push(node)\n }\n\n // filter out if the export name is the same as one that we already defined in extraNodes(see enum)\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !this.extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return [...this.extraNodes, ...filterdNodes]\n }\n\n /**\n * Creates a type node from a given schema.\n * Delegates to getBaseTypeFromSchema internally and\n * optionally adds a union with null.\n */\n getTypeFromSchema(schema?: OasTypes.SchemaObject, name?: string): ts.TypeNode | null {\n const type = this.#getBaseTypeFromSchema(schema, name)\n\n if (!type) {\n return null\n }\n\n if (schema && !schema.nullable) {\n return type\n }\n\n return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n /**\n * Recursively creates a type literal with the given props.\n */\n #getTypeFromProperties(baseSchema?: OasTypes.SchemaObject, baseName?: string): ts.TypeNode | null {\n const { optionalType } = this.options\n const properties = baseSchema?.properties || {}\n const required = baseSchema?.required\n const additionalProperties = baseSchema?.additionalProperties\n\n const members: Array<ts.TypeElement | null> = Object.keys(properties).map((name) => {\n const schema = properties[name] as OasTypes.SchemaObject\n\n const isRequired = Array.isArray(required) ? required.includes(name) : !!required\n let type = this.getTypeFromSchema(schema, this.context.pluginManager.resolveName({ name: `${baseName || ''} ${name}`, pluginKey, type: 'type' }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType as string) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n schema.description ? `@description ${schema.description}` : undefined,\n schema.type ? `@type ${schema.type?.toString()}${isRequired ? '' : ' | undefined'} ${schema.format || ''}` : undefined,\n schema.example ? `@example ${schema.example as string}` : undefined,\n schema.deprecated ? `@deprecated` : undefined,\n schema.default !== undefined && typeof schema.default === 'string' ? `@default '${schema.default}'` : undefined,\n schema.default !== undefined && typeof schema.default !== 'string' ? `@default ${schema.default as string}` : undefined,\n ].filter(Boolean),\n })\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? this.#unknownReturn : this.getTypeFromSchema(additionalProperties as OasTypes.SchemaObject)\n\n if (type) {\n members.push(factory.createIndexSignature(type))\n }\n }\n return factory.createTypeLiteralNode(members.filter(Boolean))\n }\n\n /**\n * Create a type alias for the schema referenced by the given ReferenceObject\n */\n #getRefAlias(obj: OpenAPIV3.ReferenceObject, _baseName?: string) {\n const { $ref } = obj\n let ref = this.refs[$ref]\n\n if (ref) {\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n const originalName = getUniqueName($ref.replace(/.+\\//, ''), this.#usedAliasNames)\n const propertyName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'type' })\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'file' })\n const path = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey })\n\n this.imports.push({\n ref,\n path: path || '',\n isTypeOnly: true,\n })\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n #getParsedSchema(schema?: OasTypes.SchemaObject) {\n const parsedSchema = getSchemaFactory(this.context.oas)(schema)\n return parsedSchema\n }\n\n /**\n * This is the very core of the OpenAPI to TS conversion - it takes a\n * schema and returns the appropriate type.\n */\n #getBaseTypeFromSchema(\n _schema: OasTypes.SchemaObject | undefined,\n baseName?: string,\n ): ts.TypeNode | null {\n const { schema, version } = this.#getParsedSchema(_schema)\n\n if (!schema) {\n return this.#unknownReturn\n }\n\n if (isReference(schema)) {\n return this.#getRefAlias(schema, baseName)\n }\n\n if (schema.oneOf) {\n // union\n const schemaWithoutOneOf = { ...schema, oneOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.oneOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n\n if (schema.anyOf) {\n const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.anyOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAnyOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n if (schema.allOf) {\n // intersection/add\n const schemaWithoutAllOf = { ...schema, allOf: undefined } as OasTypes.SchemaObject\n\n const and = factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes: schema.allOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean),\n })\n }\n\n return and\n }\n\n /**\n * Enum will be defined outside the baseType(hints the baseName check)\n */\n if (schema.enum && baseName) {\n const enumName = getUniqueName(baseName, this.options.usedEnumNames)\n\n let enums: [key: string, value: string | number][] = [...new Set(schema.enum)].map((key) => [key, key])\n\n const extensionEnums: Array<typeof enums> = ['x-enumNames', 'x-enum-varnames']\n .filter(extensionKey => extensionKey in schema)\n .map((extensionKey) =>\n [...new Set(schema[extensionKey as keyof typeof schema] as string[])].map((key, index) => [key, schema.enum?.[index] as string] as const)\n )\n\n if (extensionEnums.length > 0 && extensionEnums[0]) {\n enums = extensionEnums[0]\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: transformers.camelCase(enumName),\n typeName: this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }), undefined)\n }\n\n if (schema.enum) {\n return factory.createUnionDeclaration({\n nodes: schema.enum.map((name) => {\n return factory.createLiteralTypeNode(typeof name === 'number' ? factory.createNumericLiteral(name) : factory.createStringLiteral(`${name}`))\n }) as unknown as Array<ts.TypeNode>,\n })\n }\n\n if ('items' in schema) {\n // items -> array\n const node = this.getTypeFromSchema(schema.items as OasTypes.SchemaObject, baseName)\n if (node) {\n return factory.createArrayTypeNode(node)\n }\n }\n\n /**\n * OpenAPI 3.1\n * @link https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation\n */\n\n if ('prefixItems' in schema) {\n const prefixItems = schema.prefixItems as OasTypes.SchemaObject[]\n\n return factory.createTupleDeclaration({\n nodes: prefixItems.map((item) => {\n // no baseType so we can fall back on an union when using enum\n return this.getTypeFromSchema(item, undefined)\n }) as Array<ts.TypeNode>,\n })\n }\n\n if (schema.properties || schema.additionalProperties) {\n // properties -> literal type\n return this.#getTypeFromProperties(schema, baseName)\n }\n\n /**\n * validate \"const\" property as defined in JSON-Schema-Validation\n *\n * https://json-schema.org/draft/2020-12/json-schema-validation#name-const\n *\n * > 6.1.3. const\n * > The value of this keyword MAY be of any type, including null.\n * > Use of this keyword is functionally equivalent to an \"enum\" (Section 6.1.2) with a single value.\n * > An instance validates successfully against this keyword if its value is equal to the value of the keyword.\n */\n if (version === '3.1' && 'const' in schema) {\n // const keyword takes precendence over the actual type.\n if (schema['const']) {\n if (typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n } else if (typeof schema['const'] === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(schema['const']))\n }\n } else {\n return keywordTypeNodes.null\n }\n }\n\n if (schema.type) {\n if (Array.isArray(schema.type)) {\n // TODO remove hardcoded first type, second nullable\n // OPENAPI v3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n const [type, nullable] = schema.type as Array<OpenAPIV3_1.NonArraySchemaObjectType>\n\n return factory.createUnionDeclaration({\n nodes: [\n this.getTypeFromSchema(\n {\n ...schema,\n type,\n },\n baseName,\n ),\n nullable ? factory.createLiteralTypeNode(factory.createNull()) : undefined,\n ].filter(Boolean),\n })\n }\n\n if (this.options.dateType === 'date' && ['date', 'date-time'].some((item) => item === schema.format)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Date'))\n }\n\n // string, boolean, null, number\n if (schema.type in factory.keywordTypeNodes) {\n return factory.keywordTypeNodes[schema.type as keyof typeof factory.keywordTypeNodes]\n }\n }\n\n if (schema.format === 'binary') {\n return factory.createTypeReferenceNode('Blob', [])\n }\n\n return this.#unknownReturn\n }\n\n get #unknownReturn() {\n if (this.options.unknownType === 'any') {\n return factory.keywordTypeNodes.any\n }\n\n return factory.keywordTypeNodes.unknown\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { TypeBuilder } from './TypeBuilder.ts'\n\nimport type { KubbFile, Plugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = [pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = { path: 'types' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n transformers = {},\n oasType = false,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginName,\n options: {\n transformers,\n dateType,\n enumType,\n optionalType,\n oasType,\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n unknownType,\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, directory, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'file') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n\n const schemas = await swaggerPlugin.api.getSchemas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const builder = new TypeBuilder(this.plugin.options, { oas, pluginManager: this.pluginManager })\n\n builder.add(\n Object.entries(schemas).map(([name, schema]: [string, OasTypes.SchemaObject]) => ({ name, schema })),\n )\n\n if (mode === 'directory') {\n const mapFolderSchema = async ([name]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${this.resolveName({ name, pluginKey: this.plugin.key, type: 'file' })}.ts` as const\n const resolvedPath = this.resolvePath({ baseName, pluginKey: this.plugin.key })\n const { source, imports } = builder.build(name)\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName,\n source,\n imports: imports.map(item => ({ ...item, root: resolvedPath })),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapFolderSchema)\n\n await Promise.all(promises)\n }\n\n if (mode === 'file') {\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n const { source } = builder.build()\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output.path as KubbFile.BaseName,\n source,\n imports: [],\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const operationGenerator = new OperationGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n })\n },\n }\n})\n","import { createRoot } from '@kubb/react'\nimport { OperationGenerator as Generator } from '@kubb/swagger'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Oas } from './components/Oas.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult, OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async all(): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n if (!plugin.options.oasType) {\n return null\n }\n\n const root = createRoot<AppContextProps>({ logger: pluginManager.logger })\n root.render(\n <Oas.File name=\"oas\" typeName=\"Oas\" />,\n { meta: { oas, pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Query.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Mutation.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n}\n","import { File, Type, usePlugin } from '@kubb/react'\nimport { useFile } from '@kubb/react'\nimport { useOas } from '@kubb/swagger/hooks'\n\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n api: OasTypes.OASDocument\n}\n\nfunction Template({\n name,\n typeName,\n api,\n}: TemplateProps): ReactNode {\n return (\n <>\n {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}\n <br />\n <Type name={typeName} export>\n {`Infer<typeof ${name}>`}\n </Type>\n </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Oas({\n name,\n typeName,\n Template = defaultTemplates.default,\n}: Props): ReactNode {\n const oas = useOas()\n\n return <Template name={name} typeName={typeName} api={oas.api} />\n}\n\ntype FileProps = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nOas.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useFile({ name, pluginKey })\n\n const Template = templates.default\n\n return (\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n <File.Import name={['Infer']} path=\"@kubb/swagger-ts/oas\" isTypeOnly />\n <File.Source>\n <Oas Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n )\n}\n\nOas.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Query({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nQuery.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.errors)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Mutation.tsx","../src/TypeBuilder.ts","../src/TypeGenerator.ts","../src/plugin.ts","../src/OperationGenerator.tsx","../src/components/Oas.tsx","../src/components/Query.tsx"],"names":["transformers","print","factory","File","usePlugin","usePluginManager","useOas","useOperation","useOperationFile","useOperationName","useSchemas","Generator","keywordTypeNodes","Template","pluginKey","Fragment","jsx","jsxs","options","node","path","printCombinedSchema"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,QAAAC,OAAM,aAAAC,YAAW,oBAAAC,yBAAwB;AAClD,SAAS,UAAAC,SAAQ,gBAAAC,eAAc,oBAAAC,mBAAkB,oBAAAC,mBAAkB,cAAAC,mBAAkB;;;ACJrF,OAAOV,mBAAkB;AACzB,SAAS,SAAAC,cAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;;;ACH3B,SAAS,aAAAU,kBAAiB;AAC1B,OAAOX,mBAAkB;AACzB,SAAS,qBAAqB;AAC9B,YAAYE,cAAa;AACzB,SAAS,oBAAAU,yBAAwB;AACjC,SAAS,kBAAkB,mBAAmB;;;ACL9C,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,yBAAyB;;;ACLhD,SAAS,kBAAkB;AAC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BAAAc,MAACd,MAAK,QAAL,EACE;AAAA;AAAA,UACAkB,qBAAoB,aAAa,WAAW,OAAO;AAAA,WACtD;AAAA;AAAA;AAAA,EACF,GACF;AAEJ","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Mutation({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nMutation.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.request)\n .add(schemas.errors)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport { OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from './TypeGenerator.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ImportMeta } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {\n build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>> {\n const importMeta: ImportMeta[] = []\n const codes: string[] = []\n\n const generated = this.items\n .filter((operationSchema) => (name ? operationSchema.name === name : true))\n .sort(transformers.nameSorter)\n .map((operationSchema) => {\n const generator = new TypeGenerator(this.options, this.context)\n const required = Array.isArray(operationSchema.schema?.required) ? !!operationSchema.schema.required.length : !!operationSchema.schema?.required\n\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n optional: !required && !!operationSchema.name.includes('Params'),\n })\n\n importMeta.push(...generator.imports)\n\n return {\n import: {\n refs: generator.refs,\n name: operationSchema.name,\n },\n sources,\n }\n })\n .sort(refsSorter)\n\n generated.forEach((item) => {\n codes.push(print(item.sources))\n })\n\n const imports: KubbFile.Import[] = importMeta.map((item) => {\n return {\n name: [item.ref.propertyName],\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n }\n })\n\n return {\n imports,\n source: transformers.combineCodes(codes),\n }\n }\n}\n","import { Generator } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { keywordTypeNodes } from '@kubb/parser/factory'\nimport { getSchemaFactory, isReference } from '@kubb/swagger/utils'\n\nimport { pluginKey } from './plugin.ts'\n\nimport type { PluginManager } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { ImportMeta, Refs } from '@kubb/swagger'\nimport type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1 } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Context = {\n oas: Oas\n pluginManager: PluginManager\n}\n\nexport class TypeGenerator extends Generator<PluginOptions['resolvedOptions'], Context> {\n refs: Refs = {}\n imports: ImportMeta[] = []\n\n extraNodes: ts.Node[] = []\n\n aliases: ts.TypeAliasDeclaration[] = []\n\n // Keep track of already used type aliases\n #usedAliasNames: Record<string, number> = {}\n\n build({\n schema,\n optional,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OasTypes.SchemaObject\n baseName: string\n description?: string\n optional?: boolean\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n let type = this.getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n if (optional) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] }) as ts.TypeNode\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.context.pluginManager.resolveName({ name: baseName, pluginKey, type: 'type' }),\n type: keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type, nonNullable: true }) : type,\n })\n\n if (description) {\n nodes.push(\n factory.appendJSDocToNode({\n node,\n comments: [`@description ${transformers.trim(description)}`],\n }),\n )\n } else {\n nodes.push(node)\n }\n\n // filter out if the export name is the same as one that we already defined in extraNodes(see enum)\n const filterdNodes = nodes.filter(\n (node: ts.Node) =>\n !this.extraNodes.some(\n (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,\n ),\n )\n\n return [...this.extraNodes, ...filterdNodes]\n }\n\n /**\n * Creates a type node from a given schema.\n * Delegates to getBaseTypeFromSchema internally and\n * optionally adds a union with null.\n */\n getTypeFromSchema(schema?: OasTypes.SchemaObject, name?: string): ts.TypeNode | null {\n const type = this.#getBaseTypeFromSchema(schema, name)\n\n if (!type) {\n return null\n }\n\n if (schema && !schema.nullable) {\n return type\n }\n\n return factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n /**\n * Recursively creates a type literal with the given props.\n */\n #getTypeFromProperties(baseSchema?: OasTypes.SchemaObject, baseName?: string): ts.TypeNode | null {\n const { optionalType } = this.options\n const properties = baseSchema?.properties || {}\n const required = baseSchema?.required\n const additionalProperties = baseSchema?.additionalProperties\n\n const members: Array<ts.TypeElement | null> = Object.keys(properties).map((name) => {\n const schema = properties[name] as OasTypes.SchemaObject\n\n const isRequired = Array.isArray(required) ? required.includes(name) : !!required\n let type = this.getTypeFromSchema(schema, this.context.pluginManager.resolveName({ name: `${baseName || ''} ${name}`, pluginKey, type: 'type' }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType as string)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType as string) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n schema.description ? `@description ${schema.description}` : undefined,\n schema.type ? `@type ${schema.type?.toString()}${isRequired ? '' : ' | undefined'} ${schema.format || ''}` : undefined,\n schema.example ? `@example ${schema.example as string}` : undefined,\n schema.deprecated ? `@deprecated` : undefined,\n schema.default !== undefined && typeof schema.default === 'string' ? `@default '${schema.default}'` : undefined,\n schema.default !== undefined && typeof schema.default !== 'string' ? `@default ${schema.default as string}` : undefined,\n ].filter(Boolean),\n })\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? this.#unknownReturn : this.getTypeFromSchema(additionalProperties as OasTypes.SchemaObject)\n\n if (type) {\n members.push(factory.createIndexSignature(type))\n }\n }\n return factory.createTypeLiteralNode(members.filter(Boolean))\n }\n\n /**\n * Create a type alias for the schema referenced by the given ReferenceObject\n */\n #getRefAlias(obj: OpenAPIV3.ReferenceObject, _baseName?: string) {\n const { $ref } = obj\n let ref = this.refs[$ref]\n\n if (ref) {\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n const originalName = getUniqueName($ref.replace(/.+\\//, ''), this.#usedAliasNames)\n const propertyName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'type' })\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n const fileName = this.context.pluginManager.resolveName({ name: originalName, pluginKey, type: 'file' })\n const path = this.context.pluginManager.resolvePath({ baseName: fileName, pluginKey })\n\n this.imports.push({\n ref,\n path: path || '',\n isTypeOnly: true,\n })\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n #getParsedSchema(schema?: OasTypes.SchemaObject) {\n const parsedSchema = getSchemaFactory(this.context.oas)(schema)\n return parsedSchema\n }\n\n /**\n * This is the very core of the OpenAPI to TS conversion - it takes a\n * schema and returns the appropriate type.\n */\n #getBaseTypeFromSchema(\n _schema: OasTypes.SchemaObject | undefined,\n baseName?: string,\n ): ts.TypeNode | null {\n const { schema, version } = this.#getParsedSchema(_schema)\n\n if (!schema) {\n return this.#unknownReturn\n }\n\n if (isReference(schema)) {\n return this.#getRefAlias(schema, baseName)\n }\n\n if (schema.oneOf) {\n // union\n const schemaWithoutOneOf = { ...schema, oneOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.oneOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n\n if (schema.anyOf) {\n const schemaWithoutAnyOf = { ...schema, anyOf: undefined } as OasTypes.SchemaObject\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.anyOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAnyOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n if (schema.allOf) {\n // intersection/add\n const schemaWithoutAllOf = { ...schema, allOf: undefined } as OasTypes.SchemaObject\n\n const and = factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes: schema.allOf\n .map((item) => {\n return item && this.getTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== this.#unknownReturn\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.getTypeFromSchema(schemaWithoutAllOf, baseName), and].filter(Boolean),\n })\n }\n\n return and\n }\n\n /**\n * Enum will be defined outside the baseType(hints the baseName check)\n */\n if (schema.enum && baseName) {\n const enumName = getUniqueName(baseName, this.options.usedEnumNames)\n\n let enums: [key: string, value: string | number][] = [...new Set(schema.enum)].map((key) => [key, key])\n\n const extensionEnums: Array<typeof enums> = ['x-enumNames', 'x-enum-varnames']\n .filter(extensionKey => extensionKey in schema)\n .map((extensionKey) =>\n [...new Set(schema[extensionKey as keyof typeof schema] as string[])].map((key, index) => [key, schema.enum?.[index] as string] as const)\n )\n\n if (extensionEnums.length > 0 && extensionEnums[0]) {\n enums = extensionEnums[0]\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: transformers.camelCase(enumName),\n typeName: this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.context.pluginManager.resolveName({ name: enumName, pluginKey, type: 'type' }), undefined)\n }\n\n if (schema.enum) {\n return factory.createUnionDeclaration({\n nodes: schema.enum.map((name) => {\n return factory.createLiteralTypeNode(typeof name === 'number' ? factory.createNumericLiteral(name) : factory.createStringLiteral(`${name}`))\n }) as unknown as Array<ts.TypeNode>,\n })\n }\n\n if ('items' in schema) {\n // items -> array\n const node = this.getTypeFromSchema(schema.items as OasTypes.SchemaObject, baseName)\n if (node) {\n return factory.createArrayTypeNode(node)\n }\n }\n\n /**\n * OpenAPI 3.1\n * @link https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation\n */\n\n if ('prefixItems' in schema) {\n const prefixItems = schema.prefixItems as OasTypes.SchemaObject[]\n\n return factory.createTupleDeclaration({\n nodes: prefixItems.map((item) => {\n // no baseType so we can fall back on an union when using enum\n return this.getTypeFromSchema(item, undefined)\n }) as Array<ts.TypeNode>,\n })\n }\n\n if (schema.properties || schema.additionalProperties) {\n // properties -> literal type\n return this.#getTypeFromProperties(schema, baseName)\n }\n\n /**\n * validate \"const\" property as defined in JSON-Schema-Validation\n *\n * https://json-schema.org/draft/2020-12/json-schema-validation#name-const\n *\n * > 6.1.3. const\n * > The value of this keyword MAY be of any type, including null.\n * > Use of this keyword is functionally equivalent to an \"enum\" (Section 6.1.2) with a single value.\n * > An instance validates successfully against this keyword if its value is equal to the value of the keyword.\n */\n if (version === '3.1' && 'const' in schema) {\n // const keyword takes precendence over the actual type.\n if (schema['const']) {\n if (typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n } else if (typeof schema['const'] === 'number') {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(schema['const']))\n }\n } else {\n return keywordTypeNodes.null\n }\n }\n\n if (schema.type) {\n if (Array.isArray(schema.type)) {\n // TODO remove hardcoded first type, second nullable\n // OPENAPI v3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n const [type, nullable] = schema.type as Array<OpenAPIV3_1.NonArraySchemaObjectType>\n\n return factory.createUnionDeclaration({\n nodes: [\n this.getTypeFromSchema(\n {\n ...schema,\n type,\n },\n baseName,\n ),\n nullable ? factory.createLiteralTypeNode(factory.createNull()) : undefined,\n ].filter(Boolean),\n })\n }\n\n if (this.options.dateType === 'date' && ['date', 'date-time'].some((item) => item === schema.format)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Date'))\n }\n\n // string, boolean, null, number\n if (schema.type in factory.keywordTypeNodes) {\n return factory.keywordTypeNodes[schema.type as keyof typeof factory.keywordTypeNodes]\n }\n }\n\n if (schema.format === 'binary') {\n return factory.createTypeReferenceNode('Blob', [])\n }\n\n return this.#unknownReturn\n }\n\n get #unknownReturn() {\n if (this.options.unknownType === 'any') {\n return factory.keywordTypeNodes.any\n }\n\n return factory.keywordTypeNodes.unknown\n }\n}\n","import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { TypeBuilder } from './TypeBuilder.ts'\n\nimport type { KubbFile, Plugin } from '@kubb/core'\nimport type { PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { PluginOptions } from './types.ts'\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = [pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = { path: 'types' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n transformers = {},\n oasType = false,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginName,\n options: {\n transformers,\n dateType,\n enumType,\n optionalType,\n oasType,\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n usedEnumNames: {},\n unknownType,\n },\n pre: [swaggerPluginName],\n resolvePath(baseName, directory, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'file') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [swaggerPluginName])\n\n const oas = await swaggerPlugin.api.getOas()\n\n const schemas = await swaggerPlugin.api.getSchemas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const builder = new TypeBuilder(this.plugin.options, { oas, pluginManager: this.pluginManager })\n\n builder.add(\n Object.entries(schemas).map(([name, schema]: [string, OasTypes.SchemaObject]) => ({ name, schema })),\n )\n\n if (mode === 'directory') {\n const mapFolderSchema = async ([name]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${this.resolveName({ name, pluginKey: this.plugin.key, type: 'file' })}.ts` as const\n const resolvedPath = this.resolvePath({ baseName, pluginKey: this.plugin.key })\n const { source, imports } = builder.build(name)\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName,\n source,\n imports: imports.map(item => ({ ...item, root: resolvedPath })),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapFolderSchema)\n\n await Promise.all(promises)\n }\n\n if (mode === 'file') {\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n const { source } = builder.build()\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output.path as KubbFile.BaseName,\n source,\n imports: [],\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const operationGenerator = new OperationGenerator(\n this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n })\n },\n }\n})\n","import { createRoot } from '@kubb/react'\nimport { OperationGenerator as Generator } from '@kubb/swagger'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Oas } from './components/Oas.tsx'\nimport { Query } from './components/Query.tsx'\n\nimport type { AppContextProps } from '@kubb/react'\nimport type { OperationMethodResult, OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { FileMeta, PluginOptions } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginOptions['resolvedOptions'], PluginOptions> {\n async all(): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin } = this.context\n\n if (!plugin.options.oasType) {\n return null\n }\n\n const root = createRoot<AppContextProps>({ logger: pluginManager.logger })\n root.render(\n <Oas.File name=\"oas\" typeName=\"Oas\" />,\n { meta: { oas, pluginManager, plugin } },\n )\n\n return root.files\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Query.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode = 'directory' } = this.context\n\n const root = createRoot<AppContextProps<PluginOptions['appMeta']>>({ logger: pluginManager.logger })\n root.render(\n <Mutation.File mode={mode} />,\n { meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } },\n )\n\n return root.files\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: PluginOptions['resolvedOptions']): OperationMethodResult<FileMeta> {\n return this.post(operation, schemas, options)\n }\n}\n","import { File, Type, usePlugin } from '@kubb/react'\nimport { useFile } from '@kubb/react'\nimport { useOas } from '@kubb/swagger/hooks'\n\nimport type { OasTypes } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n api: OasTypes.OASDocument\n}\n\nfunction Template({\n name,\n typeName,\n api,\n}: TemplateProps): ReactNode {\n return (\n <>\n {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}\n <br />\n <Type name={typeName} export>\n {`Infer<typeof ${name}>`}\n </Type>\n </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Oas({\n name,\n typeName,\n Template = defaultTemplates.default,\n}: Props): ReactNode {\n const oas = useOas()\n\n return <Template name={name} typeName={typeName} api={oas.api} />\n}\n\ntype FileProps = {\n name: string\n typeName: string\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nOas.File = function({ name, typeName, templates = defaultTemplates }: FileProps): ReactNode {\n const { key: pluginKey } = usePlugin<PluginOptions>()\n const file = useFile({ name, pluginKey })\n\n const Template = templates.default\n\n return (\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n <File.Import name={['Infer']} path=\"@kubb/swagger-ts/oas\" isTypeOnly />\n <File.Source>\n <Oas Template={Template} name={name} typeName={typeName} />\n </File.Source>\n </File>\n )\n}\n\nOas.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { File, usePlugin, usePluginManager } from '@kubb/react'\nimport { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'\n\nimport { TypeBuilder } from '../TypeBuilder.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OperationSchemas } from '@kubb/swagger'\nimport type { Operation } from '@kubb/swagger/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Props = {\n builder: TypeBuilder\n}\n\nfunction printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {\n const properties: Record<string, ts.TypeNode> = {\n 'response': factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.response.name),\n undefined,\n ),\n }\n\n if (schemas.request) {\n properties['request'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.request.name),\n undefined,\n )\n }\n\n if (schemas.pathParams) {\n properties['pathParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.pathParams.name),\n undefined,\n )\n }\n\n if (schemas.queryParams) {\n properties['queryParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.queryParams.name),\n undefined,\n )\n }\n\n if (schemas.headerParams) {\n properties['headerParams'] = factory.createTypeReferenceNode(\n factory.createIdentifier(schemas.headerParams.name),\n undefined,\n )\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map(error => {\n return factory.createTypeReferenceNode(\n factory.createIdentifier(error.name),\n undefined,\n )\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n type: factory.createTypeLiteralNode(\n Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature(\n {\n name: transformers.pascalCase(key),\n type,\n },\n )\n }).filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport function Query({\n builder,\n}: Props): ReactNode {\n const { source } = builder.build()\n\n return (\n <>\n {source}\n </>\n )\n}\n\ntype FileProps = {\n mode: KubbFile.Mode\n}\n\nQuery.File = function({ mode }: FileProps): ReactNode {\n const { options } = usePlugin<PluginOptions>()\n\n const schemas = useSchemas()\n const pluginManager = usePluginManager()\n const oas = useOas()\n const file = useOperationFile()\n const factoryName = useOperationName({ type: 'type' })\n const operation = useOperation()\n\n const builder = new TypeBuilder(options, { oas, pluginManager })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.errors)\n\n const { source, imports } = builder.build()\n\n return (\n <>\n <File<FileMeta>\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n >\n {mode === 'directory' && imports.map((item, index) => {\n return <File.Import key={index} root={file.path} {...item} />\n })}\n <File.Source>\n {source}\n {printCombinedSchema(factoryName, operation, schemas)}\n </File.Source>\n </File>\n </>\n )\n}\n"]}