@kubb/swagger-ts 2.0.0-alpha.8 → 2.0.0-beta.1

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.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { pluginName as pluginName$1, OasBuilder, ImportsGenerator, OperationGene
6
6
  import { camelCase, camelCaseTransformMerge, pascalCase, pascalCaseTransformMerge } from 'change-case';
7
7
  import { print } from '@kubb/parser';
8
8
  import * as factory from '@kubb/parser/factory';
9
- import { refsSorter, isReference } from '@kubb/swagger/utils';
9
+ import { refsSorter, isReference, getSchemaFactory } from '@kubb/swagger/utils';
10
10
 
11
11
  createRequire(import.meta.url);
12
12
 
@@ -27,16 +27,9 @@ var __privateMethod = (obj, member, method) => {
27
27
  __accessCheck(obj, member, "access private method");
28
28
  return method;
29
29
  };
30
- var _usedAliasNames, _caseOptions, _getTypeFromSchema, getTypeFromSchema_fn, _getTypeFromProperties, getTypeFromProperties_fn, _getRefAlias, getRefAlias_fn, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn;
30
+ var _usedAliasNames, _caseOptions, _getTypeFromSchema, getTypeFromSchema_fn, _getTypeFromProperties, getTypeFromProperties_fn, _getRefAlias, getRefAlias_fn, _getParsedSchema, getParsedSchema_fn, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn;
31
31
  var TypeGenerator = class extends SchemaGenerator {
32
- constructor(options = {
33
- usedEnumNames: {},
34
- withJSDocs: true,
35
- resolveName: ({ name }) => name,
36
- enumType: "asConst",
37
- dateType: "string",
38
- optionalType: "questionToken"
39
- }) {
32
+ constructor(options) {
40
33
  super(options);
41
34
  /**
42
35
  * Creates a type node from a given schema.
@@ -52,6 +45,7 @@ var TypeGenerator = class extends SchemaGenerator {
52
45
  * Create a type alias for the schema referenced by the given ReferenceObject
53
46
  */
54
47
  __privateAdd(this, _getRefAlias);
48
+ __privateAdd(this, _getParsedSchema);
55
49
  /**
56
50
  * This is the very core of the OpenAPI to TS conversion - it takes a
57
51
  * schema and returns the appropriate type.
@@ -123,7 +117,7 @@ getTypeFromProperties_fn = function(baseSchema, baseName) {
123
117
  const additionalProperties = baseSchema?.additionalProperties;
124
118
  const members = Object.keys(properties).map((name) => {
125
119
  const schema = properties[name];
126
- const isRequired = required && required.includes(name);
120
+ const isRequired = Array.isArray(required) ? required.includes(name) : !!required;
127
121
  let type = __privateMethod(this, _getTypeFromSchema, getTypeFromSchema_fn).call(this, schema, this.options.resolveName({ name: `${baseName || ""} ${name}` }));
128
122
  if (!type) {
129
123
  return null;
@@ -142,7 +136,7 @@ getTypeFromProperties_fn = function(baseSchema, baseName) {
142
136
  node: propertySignature,
143
137
  comments: [
144
138
  schema.description ? `@description ${schema.description}` : void 0,
145
- schema.type ? `@type ${schema.type}${isRequired ? "" : " | undefined"} ${schema.format || ""}` : void 0,
139
+ schema.type ? `@type ${schema.type?.toString()}${isRequired ? "" : " | undefined"} ${schema.format || ""}` : void 0,
146
140
  schema.example ? `@example ${schema.example}` : void 0,
147
141
  schema.deprecated ? `@deprecated` : void 0,
148
142
  schema.default !== void 0 && typeof schema.default === "string" ? `@default '${schema.default}'` : void 0,
@@ -175,8 +169,14 @@ getRefAlias_fn = function(obj, _baseName) {
175
169
  };
176
170
  return factory.createTypeReferenceNode(ref.propertyName, void 0);
177
171
  };
172
+ _getParsedSchema = new WeakSet();
173
+ getParsedSchema_fn = function(schema) {
174
+ const parsedSchema = getSchemaFactory(this.options.oas)(schema);
175
+ return parsedSchema;
176
+ };
178
177
  _getBaseTypeFromSchema = new WeakSet();
179
- getBaseTypeFromSchema_fn = function(schema, baseName) {
178
+ getBaseTypeFromSchema_fn = function(_schema, baseName) {
179
+ const { schema, version } = __privateMethod(this, _getParsedSchema, getParsedSchema_fn).call(this, _schema);
180
180
  if (!schema) {
181
181
  return factory.keywordTypeNodes.any;
182
182
  }
@@ -188,7 +188,7 @@ getBaseTypeFromSchema_fn = function(schema, baseName) {
188
188
  const union = factory.createUnionDeclaration({
189
189
  withParentheses: true,
190
190
  nodes: schema.oneOf.map((item) => {
191
- return __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
191
+ return item && __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
192
192
  }).filter((item) => {
193
193
  return item && item !== factory.keywordTypeNodes.any;
194
194
  })
@@ -205,7 +205,7 @@ getBaseTypeFromSchema_fn = function(schema, baseName) {
205
205
  const union = factory.createUnionDeclaration({
206
206
  withParentheses: true,
207
207
  nodes: schema.anyOf.map((item) => {
208
- return __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
208
+ return item && __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
209
209
  }).filter((item) => {
210
210
  return item && item !== factory.keywordTypeNodes.any;
211
211
  })
@@ -222,7 +222,7 @@ getBaseTypeFromSchema_fn = function(schema, baseName) {
222
222
  const and = factory.createIntersectionDeclaration({
223
223
  withParentheses: true,
224
224
  nodes: schema.allOf.map((item) => {
225
- return __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
225
+ return item && __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
226
226
  }).filter((item) => {
227
227
  return item && item !== factory.keywordTypeNodes.any;
228
228
  })
@@ -299,7 +299,7 @@ getBaseTypeFromSchema_fn = function(schema, baseName) {
299
299
  if (schema.format === "binary") {
300
300
  return factory.createTypeReferenceNode("Blob", []);
301
301
  }
302
- if ("const" in schema && schema["const"] !== void 0 && typeof schema["const"] === "string") {
302
+ if (version === "3.1" && typeof schema["const"] === "string") {
303
303
  return factory.createLiteralTypeNode(factory.createStringLiteral(schema["const"]));
304
304
  }
305
305
  return factory.keywordTypeNodes.any;
@@ -325,7 +325,8 @@ var TypeBuilder = class extends OasBuilder {
325
325
  resolveName: this.options.resolveName,
326
326
  enumType: this.options.enumType,
327
327
  dateType: this.options.dateType,
328
- optionalType: this.options.optionalType
328
+ optionalType: this.options.optionalType,
329
+ oas: this.options.oas
329
330
  });
330
331
  const sources = generator.build({
331
332
  schema: operationSchema.schema,
@@ -381,7 +382,7 @@ var OperationGenerator = class extends OperationGenerator$1 {
381
382
  }
382
383
  async get(operation, schemas, options) {
383
384
  const { mode, enumType, dateType, optionalType, usedEnumNames } = options;
384
- const { pluginManager, plugin } = this.context;
385
+ const { pluginManager, plugin, oas } = this.context;
385
386
  const type = this.resolve(operation);
386
387
  const fileResolver = (name) => {
387
388
  const root = pluginManager.resolvePath({ baseName: type.baseName, pluginKey: plugin?.key, options: { tag: operation.getTags()[0]?.name } });
@@ -398,7 +399,8 @@ var OperationGenerator = class extends OperationGenerator$1 {
398
399
  resolveName: (params) => pluginManager.resolveName({ ...params, pluginKey: plugin?.key }),
399
400
  enumType,
400
401
  optionalType,
401
- dateType
402
+ dateType,
403
+ oas
402
404
  }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.errors).configure().print();
403
405
  const combinedSchemaSource = __privateMethod(this, _printCombinedSchema, printCombinedSchema_fn).call(this, type.name, operation, schemas);
404
406
  return {
@@ -413,7 +415,7 @@ var OperationGenerator = class extends OperationGenerator$1 {
413
415
  }
414
416
  async post(operation, schemas, options) {
415
417
  const { mode, enumType, dateType, optionalType, usedEnumNames } = options;
416
- const { pluginManager, plugin } = this.context;
418
+ const { pluginManager, plugin, oas } = this.context;
417
419
  const type = this.resolve(operation);
418
420
  const fileResolver = (name) => {
419
421
  const root = pluginManager.resolvePath({ baseName: type.baseName, pluginKey: plugin?.key, options: { tag: operation.getTags()[0]?.name } });
@@ -430,7 +432,8 @@ var OperationGenerator = class extends OperationGenerator$1 {
430
432
  resolveName: (params) => pluginManager.resolveName({ ...params, pluginKey: plugin?.key }),
431
433
  enumType,
432
434
  optionalType,
433
- dateType
435
+ dateType,
436
+ oas
434
437
  }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.request).add(schemas.response).add(schemas.errors).configure().print();
435
438
  const combinedSchemaSource = __privateMethod(this, _printCombinedSchema, printCombinedSchema_fn).call(this, type.name, operation, schemas);
436
439
  return {
@@ -550,9 +553,12 @@ var definePlugin = createPlugin((options) => {
550
553
  }
551
554
  return path.resolve(root, output, baseName);
552
555
  },
553
- resolveName(name) {
556
+ resolveName(name, type) {
554
557
  const resolvedName = pascalCase(name, { delimiter: "", stripRegexp: /[^A-Z0-9$]/gi, transform: pascalCaseTransformMerge });
555
- return transformers2?.name?.(resolvedName) || resolvedName;
558
+ if (type) {
559
+ return transformers2?.name?.(resolvedName, type) || resolvedName;
560
+ }
561
+ return resolvedName;
556
562
  },
557
563
  async writeFile(source, writePath) {
558
564
  if (!writePath.endsWith(".ts") || !source) {
@@ -582,7 +588,8 @@ var definePlugin = createPlugin((options) => {
582
588
  withJSDocs: true,
583
589
  enumType,
584
590
  dateType,
585
- optionalType
591
+ optionalType,
592
+ oas
586
593
  }).configure();
587
594
  Object.entries(schemas).forEach(([name, schema]) => {
588
595
  return builder.add({
@@ -614,7 +621,8 @@ var definePlugin = createPlugin((options) => {
614
621
  withJSDocs: true,
615
622
  enumType,
616
623
  dateType,
617
- optionalType
624
+ optionalType,
625
+ oas
618
626
  }).configure();
619
627
  Object.entries(schemas).forEach(([name, schema]) => {
620
628
  return builder.add({
@@ -689,13 +697,10 @@ var definePlugin = createPlugin((options) => {
689
697
  }
690
698
  };
691
699
  });
692
- function resolve2(props) {
693
- return resolve({ pluginKey, ...props });
694
- }
695
700
 
696
701
  // src/index.ts
697
702
  var src_default = definePlugin;
698
703
 
699
- export { src_default as default, definePlugin, pluginKey, pluginName, resolve2 as resolve };
704
+ export { src_default as default, definePlugin, pluginKey, pluginName };
700
705
  //# sourceMappingURL=out.js.map
701
706
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts","../src/builders/TypeBuilder.ts","../src/generators/TypeGenerator.ts","../src/generators/OperationGenerator.ts","../src/resolve.ts","../src/index.ts"],"names":["getRelativePath","camelCase","pascalCase","factory","node","print","transformers","options","root","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,mBAAAA,kBAAiB,sBAAsB;AAChD,SAAS,cAAc,yBAAyB;AAEhD,SAAS,aAAAC,YAAW,yBAAyB,cAAAC,aAAY,gCAAgC;;;ACLzF,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,kBAAkB;;;ACL3B,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,YAAY,aAAa;AACzB,SAAS,mBAAmB;AAE5B,SAAS,iBAAiB;AAL1B;AAuBO,IAAM,gBAAN,cAA4B,gBAA4D;AAAA,EAe7F,YACE,UAAmB;AAAA,IACjB,eAAe,CAAC;AAAA,IAChB,YAAY;AAAA,IACZ,aAAa,CAAC,EAAE,KAAK,MAAM;AAAA,IAC3B,UAAU;AAAA,IACV,UAAU;AAAA,IACV,cAAc;AAAA,EAChB,GACA;AACA,UAAM,OAAO;AAwDf;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA;AAAA;AAAA;AAAA;AAsDA;AAAA;AAAA;AAAA;AAuBA;AAAA;AAAA;AAAA;AAAA;AA9KA,gBAAa,CAAC;AAEd,sBAAwB,CAAC;AAEzB,mBAAqC,CAAC;AAGtC;AAAA,wCAA0C,CAAC;AAE3C,qCAA4B;AAAA,MAC1B,WAAW;AAAA,MACX,aAAa;AAAA,IACf;AAcE,WAAO;AAAA,EACT;AAAA,EAEA,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAKc;AACZ,UAAM,QAAmB,CAAC;AAC1B,UAAM,OAAO,sBAAK,0CAAL,WAAwB,QAAQ;AAE7C,QAAI,CAAC,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AI,UAAU;AACZ,yBAAO;AAAA,oBACL,GAAG;AAAA,oBACH,MAAM;AAAA,oBACN,SAAS,CAAC,CAAC;AAAA,kBACb;AAAA,gBACF;AACA,uBAAO;AAAA,cACT,CAAC;AAAA,YACH;AAAA,UACF;AAAA,UACA;AAAA,UACA,YAAY;AAAA,QACd;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;AIhOD,SAAS,WAAW,sBAAsB;AAMnC,SAASC,SAAQ,OAA+B;AACrD,SAAO,eAAe,EAAE,WAAW,GAAG,MAAM,CAAC;AAC/C;;;ACFA,IAAO,cAAQ","sourcesContent":["import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { getRelativePath, renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { camelCase, camelCaseTransformMerge, pascalCase, pascalCaseTransformMerge } from 'change-case'\n\nimport { TypeBuilder } from './builders/index.ts'\nimport { OperationGenerator } from './generators/index.ts'\n\nimport type { KubbFile, KubbPlugin } from '@kubb/core'\nimport type { OpenAPIV3, PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = ['schema', pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = 'types',\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n optionalType = 'questionToken',\n transformers = {},\n exportAs,\n } = options\n const template = group?.output ? group.output : `${output}/{{tag}}Controller`\n let pluginsOptions: [KubbPlugin<SwaggerPluginOptions>]\n\n return {\n name: pluginName,\n options,\n kind: 'schema',\n validate(plugins) {\n pluginsOptions = PluginManager.getDependedPlugins<SwaggerPluginOptions>(plugins, [swaggerPluginName])\n\n return true\n },\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))\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)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag, { delimiter: '', transform: camelCaseTransformMerge })\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output, baseName)\n },\n resolveName(name) {\n const resolvedName = pascalCase(name, { delimiter: '', stripRegexp: /[^A-Z0-9$]/gi, transform: pascalCaseTransformMerge })\n\n return transformers?.name?.(resolvedName) || resolvedName\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath)\n },\n async buildStart() {\n const [swaggerPlugin] = pluginsOptions\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))\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n const usedEnumNames = {}\n\n if (mode === 'directory') {\n const builder = await new TypeBuilder({\n usedEnumNames,\n resolveName: (params) => this.resolveName({ pluginKey: this.plugin.key, ...params }),\n fileResolver: (name) => {\n const resolvedTypeId = this.resolvePath({\n baseName: `${name}.ts`,\n pluginKey: this.plugin.key,\n })\n\n const root = this.resolvePath({ baseName: ``, pluginKey: this.plugin.key })\n\n return getRelativePath(root, resolvedTypeId)\n },\n withJSDocs: true,\n enumType,\n dateType,\n optionalType,\n }).configure()\n Object.entries(schemas).forEach(([name, schema]: [string, OpenAPIV3.SchemaObject]) => {\n // generate and pass through new code back to the core so it can be write to that file\n return builder.add({\n schema,\n name,\n })\n })\n\n const mapFolderSchema = async ([name]: [string, OpenAPIV3.SchemaObject]) => {\n const resolvedPath = this.resolvePath({ baseName: `${this.resolveName({ name, pluginKey: this.plugin.key })}.ts`, pluginKey: this.plugin.key })\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName: `${this.resolveName({ name, pluginKey: this.plugin.key })}.ts`,\n source: builder.print(name),\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 // outside the loop because we need to add files to just one instance to have the correct sorting, see refsSorter\n const builder = new TypeBuilder({\n usedEnumNames,\n resolveName: (params) => this.resolveName({ pluginKey: this.plugin.key, ...params }),\n withJSDocs: true,\n enumType,\n dateType,\n optionalType,\n }).configure()\n Object.entries(schemas).forEach(([name, schema]: [string, OpenAPIV3.SchemaObject]) => {\n // generate and pass through new code back to the core so it can be write to that file\n return builder.add({\n schema,\n name,\n })\n })\n\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output as KubbFile.BaseName,\n source: builder.print(),\n meta: {\n pluginKey: this.plugin.key,\n },\n validate: false,\n })\n }\n\n const operationGenerator = new OperationGenerator(\n {\n mode,\n enumType,\n dateType,\n optionalType,\n usedEnumNames,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\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 extName: '.ts',\n meta: { pluginKey: this.plugin.key },\n options: {\n map: (file) => {\n return {\n ...file,\n exports: file.exports?.map((item) => {\n if (exportAs) {\n return {\n ...item,\n name: exportAs,\n asAlias: !!exportAs,\n }\n }\n return item\n }),\n }\n },\n output,\n isTypeOnly: true,\n },\n })\n },\n }\n})\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { transformers } from '@kubb/core/utils'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { ImportsGenerator, OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from '../generators/TypeGenerator.ts'\n\nimport type { PluginContext } from '@kubb/core'\nimport type { FileResolver } from '@kubb/swagger'\n\ntype Options = {\n usedEnumNames: Record<string, number>\n\n resolveName: PluginContext['resolveName']\n fileResolver?: FileResolver\n withJSDocs?: boolean\n withImports?: boolean\n enumType: 'enum' | 'asConst' | 'asPascalConst'\n dateType: 'string' | 'date'\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'\n}\n\nexport class TypeBuilder extends OasBuilder<Options, never> {\n configure(options?: Options) {\n if (options) {\n this.options = options\n }\n\n if (this.options.fileResolver) {\n this.options.withImports = true\n }\n\n return this\n }\n\n print(name?: string): string {\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({\n usedEnumNames: this.options.usedEnumNames,\n withJSDocs: this.options.withJSDocs,\n resolveName: this.options.resolveName,\n enumType: this.options.enumType,\n dateType: this.options.dateType,\n optionalType: this.options.optionalType,\n })\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n })\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 if (this.options.withImports) {\n const importsGenerator = new ImportsGenerator({ fileResolver: this.options.fileResolver })\n const importMeta = importsGenerator.build(generated.map((item) => item.import))\n\n if (importMeta) {\n const nodes = importMeta.map((item) => {\n return factory.createImportDeclaration({\n name: [{ propertyName: item.ref.propertyName }],\n path: item.path,\n isTypeOnly: true,\n })\n })\n\n codes.unshift(print(nodes))\n }\n }\n\n return transformers.combineCodes(codes)\n }\n}\n","import { SchemaGenerator } from '@kubb/core'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { isReference } from '@kubb/swagger/utils'\n\nimport { camelCase } from 'change-case'\n\nimport type { PluginContext } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { OpenAPIV3, Refs } from '@kubb/swagger'\nimport type { Options as CaseOptions } from 'change-case'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Options = {\n usedEnumNames: Record<string, number>\n\n withJSDocs?: boolean\n resolveName: PluginContext['resolveName']\n enumType: 'enum' | 'asConst' | 'asPascalConst'\n dateType: 'string' | 'date'\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'\n}\nexport class TypeGenerator extends SchemaGenerator<Options, OpenAPIV3.SchemaObject, ts.Node[]> {\n refs: Refs = {}\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 #caseOptions: CaseOptions = {\n delimiter: '',\n stripRegexp: /[^A-Z0-9$]/gi,\n }\n\n constructor(\n options: Options = {\n usedEnumNames: {},\n withJSDocs: true,\n resolveName: ({ name }) => name,\n enumType: 'asConst',\n dateType: 'string',\n optionalType: 'questionToken',\n },\n ) {\n super(options)\n\n return this\n }\n\n build({\n schema,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OpenAPIV3.SchemaObject\n baseName: string\n description?: string\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n const type = this.#getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.options.resolveName({ name: baseName }) || baseName,\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 ${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?: OpenAPIV3.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?: OpenAPIV3.SchemaObject, baseName?: string) {\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 OpenAPIV3.SchemaObject\n\n const isRequired = required && required.includes(name)\n let type = this.#getTypeFromSchema(schema, this.options.resolveName({ name: `${baseName || ''} ${name}` }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n if (this.options.withJSDocs) {\n return factory.appendJSDocToNode({\n node: propertySignature,\n comments: [\n schema.description ? `@description ${schema.description}` : undefined,\n schema.type ? `@type ${schema.type}${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\n return propertySignature\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? factory.keywordTypeNodes.any : this.#getTypeFromSchema(additionalProperties as OpenAPIV3.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.options.resolveName({ name: originalName }) || originalName\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\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(schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined, baseName?: string): ts.TypeNode | null {\n if (!schema) {\n return factory.keywordTypeNodes.any\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 }\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.oneOf\n .map((item: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject) => {\n return this.#getBaseTypeFromSchema(item)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.#getBaseTypeFromSchema(schemaWithoutOneOf, baseName), union].filter(Boolean),\n })\n }\n\n return union\n }\n\n if (schema.anyOf) {\n const schemaWithoutAnyOf = { ...schema, anyOf: undefined }\n\n const union = factory.createUnionDeclaration({\n withParentheses: true,\n nodes: schema.anyOf\n .map((item: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject) => {\n return this.#getBaseTypeFromSchema(item)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.#getBaseTypeFromSchema(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 }\n\n const and = factory.createIntersectionDeclaration({\n withParentheses: true,\n nodes: schema.allOf\n .map((item: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject) => {\n return this.#getBaseTypeFromSchema(item)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.#getBaseTypeFromSchema(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 if ('x-enumNames' in schema) {\n enums = [...new Set(schema['x-enumNames'] as string[])].map((key: string, index) => {\n return [key, schema.enum?.[index]]\n })\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: camelCase(enumName, this.#caseOptions),\n typeName: this.options.resolveName({ name: enumName }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.options.resolveName({ name: enumName }), undefined)\n }\n\n if (schema.enum) {\n return factory.createUnionDeclaration({\n nodes: schema.enum.map((name: string) => {\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 OpenAPIV3.SchemaObject, baseName)\n if (node) {\n return factory.createArrayTypeNode(node)\n }\n }\n /**\n * OpenAPI 3.1\n * @link https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation\n */\n if ('prefixItems' in schema) {\n const prefixItems = schema.prefixItems as OpenAPIV3.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.#getBaseTypeFromSchema(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 if (schema.type) {\n if (Array.isArray(schema.type)) {\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.NonArraySchemaObjectType>\n\n return factory.createUnionDeclaration({\n nodes: [\n this.#getBaseTypeFromSchema(\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 // detect assertion \"const\" and define the type property as a Literal\n if ('const' in schema && schema['const'] !== undefined && typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n }\n\n return factory.keywordTypeNodes.any\n }\n}\n","import { getRelativePath } from '@kubb/core/utils'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { OperationGenerator as Generator, resolve } from '@kubb/swagger'\n\nimport { pascalCase } from 'change-case'\n\nimport { TypeBuilder } from '../builders/index.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { FileResolver, Operation, OperationSchemas, Resolver } from '@kubb/swagger'\nimport type ts from 'typescript'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Options = {\n usedEnumNames: Record<string, number>\n\n mode: KubbFile.Mode\n enumType: NonNullable<PluginOptions['options']['enumType']>\n dateType: NonNullable<PluginOptions['options']['dateType']>\n optionalType: NonNullable<PluginOptions['options']['optionalType']>\n}\n\nexport class OperationGenerator extends Generator<Options, PluginOptions> {\n resolve(operation: Operation): Resolver {\n const { pluginManager, plugin } = this.context\n\n return resolve({\n operation,\n resolveName: pluginManager.resolveName,\n resolvePath: pluginManager.resolvePath,\n pluginKey: plugin?.key,\n })\n }\n\n async all(): Promise<KubbFile.File | null> {\n return null\n }\n\n #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.createNamespaceDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n statements: Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n return factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: pascalCase(key),\n type,\n })\n }).filter(Boolean),\n })\n\n return print(namespaceNode)\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n const { mode, enumType, dateType, optionalType, usedEnumNames } = options\n const { pluginManager, plugin } = this.context\n\n const type = this.resolve(operation)\n\n const fileResolver: FileResolver = (name) => {\n // Used when a react-query type(request, response, params) has an import of a global type\n const root = pluginManager.resolvePath({ baseName: type.baseName, pluginKey: plugin?.key, options: { tag: operation.getTags()[0]?.name } })\n // refs import, will always been created with the SwaggerTS plugin, our global type\n const resolvedTypeId = pluginManager.resolvePath({\n baseName: `${name}.ts`,\n pluginKey: plugin?.key,\n })\n\n return getRelativePath(root, resolvedTypeId)\n }\n\n const source = new TypeBuilder({\n usedEnumNames,\n fileResolver: mode === 'file' ? undefined : fileResolver,\n withJSDocs: true,\n resolveName: (params) => pluginManager.resolveName({ ...params, pluginKey: plugin?.key }),\n enumType,\n optionalType,\n dateType,\n })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.errors)\n .configure()\n .print()\n\n const combinedSchemaSource = this.#printCombinedSchema(type.name, operation, schemas)\n\n return {\n path: type.path,\n baseName: type.baseName,\n source: [source, combinedSchemaSource].join('\\n'),\n meta: {\n pluginKey: plugin.key,\n tag: operation.getTags()[0]?.name,\n },\n }\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n const { mode, enumType, dateType, optionalType, usedEnumNames } = options\n const { pluginManager, plugin } = this.context\n\n const type = this.resolve(operation)\n\n const fileResolver: FileResolver = (name) => {\n // Used when a react-query type(request, response, params) has an import of a global type\n const root = pluginManager.resolvePath({ baseName: type.baseName, pluginKey: plugin?.key, options: { tag: operation.getTags()[0]?.name } })\n // refs import, will always been created with the SwaggerTS plugin, our global type\n const resolvedTypeId = pluginManager.resolvePath({\n baseName: `${name}.ts`,\n pluginKey: plugin?.key,\n })\n\n return getRelativePath(root, resolvedTypeId)\n }\n\n const source = new TypeBuilder({\n usedEnumNames,\n fileResolver: mode === 'file' ? undefined : fileResolver,\n withJSDocs: true,\n resolveName: (params) => pluginManager.resolveName({ ...params, pluginKey: plugin?.key }),\n enumType,\n optionalType,\n dateType,\n })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.request)\n .add(schemas.response)\n .add(schemas.errors)\n .configure()\n .print()\n\n const combinedSchemaSource = this.#printCombinedSchema(type.name, operation, schemas)\n\n return {\n path: type.path,\n baseName: type.baseName,\n source: [source, combinedSchemaSource].join('\\n'),\n meta: {\n pluginKey: plugin.key,\n tag: operation.getTags()[0]?.name,\n },\n }\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n return this.post(operation, schemas, options)\n }\n}\n","import { resolve as swaggerResolve } from '@kubb/swagger'\n\nimport { pluginKey } from './plugin.ts'\n\nimport type { ResolveProps, Resolver } from '@kubb/swagger'\n\nexport function resolve(props: ResolveProps): Resolver {\n return swaggerResolve({ pluginKey, ...props })\n}\n","import { definePlugin } from './plugin.ts'\n\nexport * from './plugin.ts'\nexport { resolve } from './resolve.ts'\nexport * from './types.ts'\n\nexport default definePlugin\n"]}
1
+ {"version":3,"sources":["../src/plugin.ts","../src/builders/TypeBuilder.ts","../src/generators/TypeGenerator.ts","../src/generators/OperationGenerator.ts","../src/index.ts"],"names":["getRelativePath","camelCase","pascalCase","factory","node","print","transformers","options","root"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,cAAc,aAAa,qBAAqB;AACzD,SAAS,mBAAAA,kBAAiB,sBAAsB;AAChD,SAAS,cAAc,yBAAyB;AAEhD,SAAS,aAAAC,YAAW,yBAAyB,cAAAC,aAAY,gCAAgC;;;ACLzF,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AACtB,YAAYC,cAAa;AACzB,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,kBAAkB;;;ACL3B,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,YAAY,aAAa;AACzB,SAAS,kBAAkB,mBAAmB;AAE9C,SAAS,iBAAiB;AAL1B;AAyBO,IAAM,gBAAN,cAA4B,gBAA2D;AAAA,EAe5F,YACE,SACA;AACA,UAAM,OAAO;AAwDf;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA;AAAA;AAAA;AAAA;AAsDA;AAAA;AAAA;AAAA;AAmBA;AASA;AAAA;AAAA;AAAA;AAAA;AA5KA,gBAAa,CAAC;AAEd,sBAAwB,CAAC;AAEzB,mBAAqC,CAAC;AAGtC;AAAA,wCAA0C,CAAC;AAE3C,qCAA4B;AAAA,MAC1B,WAAW;AAAA,MACX,aAAa;AAAA,IACf;AAOE,WAAO;AAAA,EACT;AAAA,EAEA,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAKc;AACZ,UAAM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M,KAAK,QAAQ,GAAG,KAAK;AAAA,IAC7B;AAAA,IACA,MAAM,WAAW;AACf,UAAI,KAAK,OAAO,OAAO,UAAU,OAAO;AACtC;AAAA,MACF;AAEA,YAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,IAAI;AAEnE,YAAM,KAAK,YAAY,WAAW;AAAA,QAChC;AAAA,QACA,SAAS;AAAA,QACT,MAAM,EAAE,WAAW,KAAK,OAAO,IAAI;AAAA,QACnC,SAAS;AAAA,UACP,KAAK,CAAC,SAAS;AACb,mBAAO;AAAA,cACL,GAAG;AAAA,cACH,SAAS,KAAK,SAAS,IAAI,CAAC,SAAS;AACnC,oBAAI,UAAU;AACZ,yBAAO;AAAA,oBACL,GAAG;AAAA,oBACH,MAAM;AAAA,oBACN,SAAS,CAAC,CAAC;AAAA,kBACb;AAAA,gBACF;AACA,uBAAO;AAAA,cACT,CAAC;AAAA,YACH;AAAA,UACF;AAAA,UACA;AAAA,UACA,YAAY;AAAA,QACd;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;AIjOD,IAAO,cAAQ","sourcesContent":["import path from 'node:path'\n\nimport { createPlugin, FileManager, PluginManager } from '@kubb/core'\nimport { getRelativePath, renderTemplate } from '@kubb/core/utils'\nimport { pluginName as swaggerPluginName } from '@kubb/swagger'\n\nimport { camelCase, camelCaseTransformMerge, pascalCase, pascalCaseTransformMerge } from 'change-case'\n\nimport { TypeBuilder } from './builders/index.ts'\nimport { OperationGenerator } from './generators/index.ts'\n\nimport type { KubbFile, KubbPlugin } from '@kubb/core'\nimport type { OasTypes, PluginOptions as SwaggerPluginOptions } from '@kubb/swagger'\nimport type { PluginOptions } from './types.ts'\n\nexport const pluginName = 'swagger-ts' satisfies PluginOptions['name']\nexport const pluginKey: PluginOptions['key'] = ['schema', pluginName] satisfies PluginOptions['key']\n\nexport const definePlugin = createPlugin<PluginOptions>((options) => {\n const {\n output = 'types',\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n dateType = 'string',\n optionalType = 'questionToken',\n transformers = {},\n exportAs,\n } = options\n const template = group?.output ? group.output : `${output}/{{tag}}Controller`\n let pluginsOptions: [KubbPlugin<SwaggerPluginOptions>]\n\n return {\n name: pluginName,\n options,\n kind: 'schema',\n validate(plugins) {\n pluginsOptions = PluginManager.getDependedPlugins<SwaggerPluginOptions>(plugins, [swaggerPluginName])\n\n return true\n },\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))\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)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag, { delimiter: '', transform: camelCaseTransformMerge })\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { delimiter: '', stripRegexp: /[^A-Z0-9$]/gi, transform: pascalCaseTransformMerge })\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)\n },\n async buildStart() {\n const [swaggerPlugin] = pluginsOptions\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))\n // keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)\n const usedEnumNames = {}\n\n if (mode === 'directory') {\n const builder = await new TypeBuilder({\n usedEnumNames,\n resolveName: (params) => this.resolveName({ pluginKey: this.plugin.key, ...params }),\n fileResolver: (name) => {\n const resolvedTypeId = this.resolvePath({\n baseName: `${name}.ts`,\n pluginKey: this.plugin.key,\n })\n\n const root = this.resolvePath({ baseName: ``, pluginKey: this.plugin.key })\n\n return getRelativePath(root, resolvedTypeId)\n },\n withJSDocs: true,\n enumType,\n dateType,\n optionalType,\n oas,\n }).configure()\n Object.entries(schemas).forEach(([name, schema]: [string, OasTypes.SchemaObject]) => {\n // generate and pass through new code back to the core so it can be write to that file\n return builder.add({\n schema,\n name,\n })\n })\n\n const mapFolderSchema = async ([name]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({ baseName: `${this.resolveName({ name, pluginKey: this.plugin.key })}.ts`, pluginKey: this.plugin.key })\n\n if (!resolvedPath) {\n return null\n }\n\n return this.addFile({\n path: resolvedPath,\n baseName: `${this.resolveName({ name, pluginKey: this.plugin.key })}.ts`,\n source: builder.print(name),\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 // outside the loop because we need to add files to just one instance to have the correct sorting, see refsSorter\n const builder = new TypeBuilder({\n usedEnumNames,\n resolveName: (params) => this.resolveName({ pluginKey: this.plugin.key, ...params }),\n withJSDocs: true,\n enumType,\n dateType,\n optionalType,\n oas,\n }).configure()\n Object.entries(schemas).forEach(([name, schema]: [string, OasTypes.SchemaObject]) => {\n // generate and pass through new code back to the core so it can be write to that file\n return builder.add({\n schema,\n name,\n })\n })\n\n const resolvedPath = this.resolvePath({ baseName: '', pluginKey: this.plugin.key })\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: output as KubbFile.BaseName,\n source: builder.print(),\n meta: {\n pluginKey: this.plugin.key,\n },\n validate: false,\n })\n }\n\n const operationGenerator = new OperationGenerator(\n {\n mode,\n enumType,\n dateType,\n optionalType,\n usedEnumNames,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\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 extName: '.ts',\n meta: { pluginKey: this.plugin.key },\n options: {\n map: (file) => {\n return {\n ...file,\n exports: file.exports?.map((item) => {\n if (exportAs) {\n return {\n ...item,\n name: exportAs,\n asAlias: !!exportAs,\n }\n }\n return item\n }),\n }\n },\n output,\n isTypeOnly: true,\n },\n })\n },\n }\n})\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { transformers } from '@kubb/core/utils'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { ImportsGenerator, OasBuilder } from '@kubb/swagger'\nimport { refsSorter } from '@kubb/swagger/utils'\n\nimport { TypeGenerator } from '../generators/TypeGenerator.ts'\n\nimport type { PluginContext } from '@kubb/core'\nimport type { FileResolver, Oas } from '@kubb/swagger'\n\ntype Options = {\n oas: Oas\n usedEnumNames: Record<string, number>\n resolveName: PluginContext['resolveName']\n fileResolver?: FileResolver\n withJSDocs?: boolean\n withImports?: boolean\n enumType: 'enum' | 'asConst' | 'asPascalConst'\n dateType: 'string' | 'date'\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'\n}\n\nexport class TypeBuilder extends OasBuilder<Options, never> {\n configure(options?: Options) {\n if (options) {\n this.options = options\n }\n\n if (this.options.fileResolver) {\n this.options.withImports = true\n }\n\n return this\n }\n\n print(name?: string): string {\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({\n usedEnumNames: this.options.usedEnumNames,\n withJSDocs: this.options.withJSDocs,\n resolveName: this.options.resolveName,\n enumType: this.options.enumType,\n dateType: this.options.dateType,\n optionalType: this.options.optionalType,\n oas: this.options.oas,\n })\n const sources = generator.build({\n schema: operationSchema.schema,\n baseName: operationSchema.name,\n description: operationSchema.description,\n keysToOmit: operationSchema.keysToOmit,\n })\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 if (this.options.withImports) {\n const importsGenerator = new ImportsGenerator({ fileResolver: this.options.fileResolver })\n const importMeta = importsGenerator.build(generated.map((item) => item.import))\n\n if (importMeta) {\n const nodes = importMeta.map((item) => {\n return factory.createImportDeclaration({\n name: [{ propertyName: item.ref.propertyName }],\n path: item.path,\n isTypeOnly: true,\n })\n })\n\n codes.unshift(print(nodes))\n }\n }\n\n return transformers.combineCodes(codes)\n }\n}\n","import { SchemaGenerator } from '@kubb/core'\nimport { getUniqueName } from '@kubb/core/utils'\nimport * as factory from '@kubb/parser/factory'\nimport { getSchemaFactory, isReference } from '@kubb/swagger/utils'\n\nimport { camelCase } from 'change-case'\n\nimport type { PluginContext } from '@kubb/core'\nimport type { ts } from '@kubb/parser'\nimport type { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1, Refs } from '@kubb/swagger'\nimport type { Options as CaseOptions } from 'change-case'\n\n// based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n\ntype Options = {\n oas: Oas\n usedEnumNames: Record<string, number>\n\n withJSDocs?: boolean\n resolveName: PluginContext['resolveName']\n enumType: 'enum' | 'asConst' | 'asPascalConst'\n dateType: 'string' | 'date'\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'\n}\n\nexport class TypeGenerator extends SchemaGenerator<Options, OasTypes.SchemaObject, ts.Node[]> {\n refs: Refs = {}\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 #caseOptions: CaseOptions = {\n delimiter: '',\n stripRegexp: /[^A-Z0-9$]/gi,\n }\n\n constructor(\n options: Options,\n ) {\n super(options)\n\n return this\n }\n\n build({\n schema,\n baseName,\n description,\n keysToOmit,\n }: {\n schema: OasTypes.SchemaObject\n baseName: string\n description?: string\n keysToOmit?: string[]\n }): ts.Node[] {\n const nodes: ts.Node[] = []\n const type = this.#getTypeFromSchema(schema, baseName)\n\n if (!type) {\n return this.extraNodes\n }\n\n const node = factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: this.options.resolveName({ name: baseName }) || baseName,\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 ${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) {\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.options.resolveName({ name: `${baseName || ''} ${name}` }))\n\n if (!type) {\n return null\n }\n\n if (!isRequired && ['undefined', 'questionTokenAndUndefined'].includes(optionalType)) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n const propertySignature = factory.createPropertySignature({\n questionToken: ['questionToken', 'questionTokenAndUndefined'].includes(optionalType) && !isRequired,\n name,\n type: type as ts.TypeNode,\n readOnly: schema.readOnly,\n })\n if (this.options.withJSDocs) {\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\n return propertySignature\n })\n if (additionalProperties) {\n const type = additionalProperties === true ? factory.keywordTypeNodes.any : 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.options.resolveName({ name: originalName }) || originalName\n\n ref = this.refs[$ref] = {\n propertyName,\n originalName,\n }\n\n return factory.createTypeReferenceNode(ref.propertyName, undefined)\n }\n\n #getParsedSchema(schema?: OasTypes.SchemaObject) {\n const parsedSchema = getSchemaFactory(this.options.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 factory.keywordTypeNodes.any\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.#getBaseTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutOneOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.#getBaseTypeFromSchema(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.#getBaseTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAnyOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.#getBaseTypeFromSchema(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.#getBaseTypeFromSchema(item as OasTypes.SchemaObject)\n })\n .filter((item) => {\n return item && item !== factory.keywordTypeNodes.any\n }) as Array<ts.TypeNode>,\n })\n\n if (schemaWithoutAllOf.properties) {\n return factory.createIntersectionDeclaration({\n nodes: [this.#getBaseTypeFromSchema(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 if ('x-enumNames' in schema) {\n enums = [...new Set(schema['x-enumNames'] as string[])].map((key: string, index) => {\n return [key, schema.enum?.[index] as string]\n })\n }\n\n this.extraNodes.push(\n ...factory.createEnumDeclaration({\n name: camelCase(enumName, this.#caseOptions),\n typeName: this.options.resolveName({ name: enumName }),\n enums,\n type: this.options.enumType,\n }),\n )\n return factory.createTypeReferenceNode(this.options.resolveName({ name: enumName }), 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.#getBaseTypeFromSchema(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 if (schema.type) {\n if (Array.isArray(schema.type)) {\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.#getBaseTypeFromSchema(\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 // detect assertion \"const\" and define the type property as a Literal\n if (version === '3.1' && typeof schema['const'] === 'string') {\n return factory.createLiteralTypeNode(factory.createStringLiteral(schema['const']))\n }\n\n return factory.keywordTypeNodes.any\n }\n}\n","import { getRelativePath } from '@kubb/core/utils'\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\nimport { OperationGenerator as Generator, resolve } from '@kubb/swagger'\n\nimport { pascalCase } from 'change-case'\n\nimport { TypeBuilder } from '../builders/index.ts'\n\nimport type { KubbFile } from '@kubb/core'\nimport type { FileResolver, Operation, OperationSchemas, Resolver } from '@kubb/swagger'\nimport type ts from 'typescript'\nimport type { FileMeta, PluginOptions } from '../types.ts'\n\ntype Options = {\n usedEnumNames: Record<string, number>\n\n mode: KubbFile.Mode\n enumType: NonNullable<PluginOptions['options']['enumType']>\n dateType: NonNullable<PluginOptions['options']['dateType']>\n optionalType: NonNullable<PluginOptions['options']['optionalType']>\n}\n\nexport class OperationGenerator extends Generator<Options, PluginOptions> {\n resolve(operation: Operation): Resolver {\n const { pluginManager, plugin } = this.context\n\n return resolve({\n operation,\n resolveName: pluginManager.resolveName,\n resolvePath: pluginManager.resolvePath,\n pluginKey: plugin?.key,\n })\n }\n\n async all(): Promise<KubbFile.File | null> {\n return null\n }\n\n #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.createNamespaceDeclaration({\n name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,\n statements: Object.keys(properties).map(key => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n return factory.createTypeAliasDeclaration({\n modifiers: [factory.modifiers.export],\n name: pascalCase(key),\n type,\n })\n }).filter(Boolean),\n })\n\n return print(namespaceNode)\n }\n\n async get(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n const { mode, enumType, dateType, optionalType, usedEnumNames } = options\n const { pluginManager, plugin, oas } = this.context\n\n const type = this.resolve(operation)\n\n const fileResolver: FileResolver = (name) => {\n // Used when a react-query type(request, response, params) has an import of a global type\n const root = pluginManager.resolvePath({ baseName: type.baseName, pluginKey: plugin?.key, options: { tag: operation.getTags()[0]?.name } })\n // refs import, will always been created with the SwaggerTS plugin, our global type\n const resolvedTypeId = pluginManager.resolvePath({\n baseName: `${name}.ts`,\n pluginKey: plugin?.key,\n })\n\n return getRelativePath(root, resolvedTypeId)\n }\n\n const source = new TypeBuilder({\n usedEnumNames,\n fileResolver: mode === 'file' ? undefined : fileResolver,\n withJSDocs: true,\n resolveName: (params) => pluginManager.resolveName({ ...params, pluginKey: plugin?.key }),\n enumType,\n optionalType,\n dateType,\n oas,\n })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.response)\n .add(schemas.errors)\n .configure()\n .print()\n\n const combinedSchemaSource = this.#printCombinedSchema(type.name, operation, schemas)\n\n return {\n path: type.path,\n baseName: type.baseName,\n source: [source, combinedSchemaSource].join('\\n'),\n meta: {\n pluginKey: plugin.key,\n tag: operation.getTags()[0]?.name,\n },\n }\n }\n\n async post(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n const { mode, enumType, dateType, optionalType, usedEnumNames } = options\n const { pluginManager, plugin, oas } = this.context\n\n const type = this.resolve(operation)\n\n const fileResolver: FileResolver = (name) => {\n // Used when a react-query type(request, response, params) has an import of a global type\n const root = pluginManager.resolvePath({ baseName: type.baseName, pluginKey: plugin?.key, options: { tag: operation.getTags()[0]?.name } })\n // refs import, will always been created with the SwaggerTS plugin, our global type\n const resolvedTypeId = pluginManager.resolvePath({\n baseName: `${name}.ts`,\n pluginKey: plugin?.key,\n })\n\n return getRelativePath(root, resolvedTypeId)\n }\n\n const source = new TypeBuilder({\n usedEnumNames,\n fileResolver: mode === 'file' ? undefined : fileResolver,\n withJSDocs: true,\n resolveName: (params) => pluginManager.resolveName({ ...params, pluginKey: plugin?.key }),\n enumType,\n optionalType,\n dateType,\n oas,\n })\n .add(schemas.pathParams)\n .add(schemas.queryParams)\n .add(schemas.headerParams)\n .add(schemas.request)\n .add(schemas.response)\n .add(schemas.errors)\n .configure()\n .print()\n\n const combinedSchemaSource = this.#printCombinedSchema(type.name, operation, schemas)\n\n return {\n path: type.path,\n baseName: type.baseName,\n source: [source, combinedSchemaSource].join('\\n'),\n meta: {\n pluginKey: plugin.key,\n tag: operation.getTags()[0]?.name,\n },\n }\n }\n\n async put(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n return this.post(operation, schemas, options)\n }\n async patch(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n return this.post(operation, schemas, options)\n }\n async delete(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {\n return this.post(operation, schemas, options)\n }\n}\n","import { definePlugin } from './plugin.ts'\n\nexport { definePlugin, pluginKey, pluginName } from './plugin.ts'\nexport * from './types.ts'\n\nexport default definePlugin\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/swagger-ts",
3
- "version": "2.0.0-alpha.8",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Generator swagger-ts",
5
5
  "keywords": [
6
6
  "typescript",
@@ -25,11 +25,6 @@
25
25
  "require": "./dist/index.cjs",
26
26
  "default": "./dist/index.cjs"
27
27
  },
28
- "./hooks": {
29
- "import": "./dist/hooks.js",
30
- "require": "./dist/hooks.cjs",
31
- "default": "./dist/hooks.cjs"
32
- },
33
28
  "./package.json": "./package.json",
34
29
  "./*": "./*"
35
30
  },
@@ -44,20 +39,20 @@
44
39
  ],
45
40
  "dependencies": {
46
41
  "change-case": "^4.1.2",
47
- "typescript": "rc",
48
- "@kubb/core": "2.0.0-alpha.8",
49
- "@kubb/swagger": "2.0.0-alpha.8",
50
- "@kubb/parser": "2.0.0-alpha.8"
42
+ "typescript": "^5.3.2",
43
+ "@kubb/core": "2.0.0-beta.1",
44
+ "@kubb/parser": "2.0.0-beta.1",
45
+ "@kubb/swagger": "2.0.0-beta.1"
51
46
  },
52
47
  "devDependencies": {
53
- "eslint": "^8.53.0",
54
- "tsup": "^7.2.0",
48
+ "eslint": "^8.54.0",
49
+ "tsup": "^8.0.1",
55
50
  "@kubb/eslint-config": "1.1.8",
56
51
  "@kubb/ts-config": "0.1.0",
57
52
  "@kubb/tsup-config": "1.1.8"
58
53
  },
59
54
  "peerDependencies": {
60
- "typescript": "rc"
55
+ "typescript": "^5.3.0"
61
56
  },
62
57
  "packageManager": "pnpm@8.3.0",
63
58
  "engines": {
@@ -74,8 +69,7 @@
74
69
  "lint": "ESLINT_USE_FLAT_CONFIG=true eslint --format pretty .",
75
70
  "lint-fix": "bun run lint --quiet --fix",
76
71
  "release": "pnpm publish --no-git-check",
77
- "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check -tag canary",
78
- "release:alpha": "bash ../../.github/canary.sh && node ../../scripts/build.js alpha && pnpm publish --no-git-check -tag alpha",
72
+ "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
79
73
  "start": "tsup --watch",
80
74
  "test": "vitest --passWithNoTests",
81
75
  "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
@@ -8,11 +8,11 @@ import { refsSorter } from '@kubb/swagger/utils'
8
8
  import { TypeGenerator } from '../generators/TypeGenerator.ts'
9
9
 
10
10
  import type { PluginContext } from '@kubb/core'
11
- import type { FileResolver } from '@kubb/swagger'
11
+ import type { FileResolver, Oas } from '@kubb/swagger'
12
12
 
13
13
  type Options = {
14
+ oas: Oas
14
15
  usedEnumNames: Record<string, number>
15
-
16
16
  resolveName: PluginContext['resolveName']
17
17
  fileResolver?: FileResolver
18
18
  withJSDocs?: boolean
@@ -49,6 +49,7 @@ export class TypeBuilder extends OasBuilder<Options, never> {
49
49
  enumType: this.options.enumType,
50
50
  dateType: this.options.dateType,
51
51
  optionalType: this.options.optionalType,
52
+ oas: this.options.oas,
52
53
  })
53
54
  const sources = generator.build({
54
55
  schema: operationSchema.schema,
@@ -104,7 +104,7 @@ export class OperationGenerator extends Generator<Options, PluginOptions> {
104
104
 
105
105
  async get(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {
106
106
  const { mode, enumType, dateType, optionalType, usedEnumNames } = options
107
- const { pluginManager, plugin } = this.context
107
+ const { pluginManager, plugin, oas } = this.context
108
108
 
109
109
  const type = this.resolve(operation)
110
110
 
@@ -128,6 +128,7 @@ export class OperationGenerator extends Generator<Options, PluginOptions> {
128
128
  enumType,
129
129
  optionalType,
130
130
  dateType,
131
+ oas,
131
132
  })
132
133
  .add(schemas.pathParams)
133
134
  .add(schemas.queryParams)
@@ -152,7 +153,7 @@ export class OperationGenerator extends Generator<Options, PluginOptions> {
152
153
 
153
154
  async post(operation: Operation, schemas: OperationSchemas, options: Options): Promise<KubbFile.File<FileMeta> | null> {
154
155
  const { mode, enumType, dateType, optionalType, usedEnumNames } = options
155
- const { pluginManager, plugin } = this.context
156
+ const { pluginManager, plugin, oas } = this.context
156
157
 
157
158
  const type = this.resolve(operation)
158
159
 
@@ -176,6 +177,7 @@ export class OperationGenerator extends Generator<Options, PluginOptions> {
176
177
  enumType,
177
178
  optionalType,
178
179
  dateType,
180
+ oas,
179
181
  })
180
182
  .add(schemas.pathParams)
181
183
  .add(schemas.queryParams)