@kubb/swagger-ts 2.0.0-alpha.9 → 2.0.0-beta.2
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/README.md +1 -1
- package/dist/index.cjs +31 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +33 -33
- package/dist/index.js.map +1 -1
- package/package.json +11 -12
- package/src/builders/TypeBuilder.ts +3 -2
- package/src/generators/OperationGenerator.ts +4 -2
- package/src/generators/TypeGenerator.ts +41 -34
- package/src/plugin.ts +9 -13
- package/src/types.ts +1 -1
package/README.md
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
</p>
|
20
20
|
|
21
21
|
<h4>
|
22
|
-
<a href="https://codesandbox.io/s/github/kubb-project/kubb/tree/
|
22
|
+
<a href="https://codesandbox.io/s/github/kubb-project/kubb/tree/alpha/examples/typescript" target="_blank">View Demo</a>
|
23
23
|
<span> · </span>
|
24
24
|
<a href="https://kubb.dev/" target="_blank">Documentation</a>
|
25
25
|
<span> · </span>
|
package/dist/index.cjs
CHANGED
@@ -51,16 +51,9 @@ var __privateMethod = (obj, member, method) => {
|
|
51
51
|
__accessCheck(obj, member, "access private method");
|
52
52
|
return method;
|
53
53
|
};
|
54
|
-
var _usedAliasNames, _caseOptions, _getTypeFromSchema, getTypeFromSchema_fn, _getTypeFromProperties, getTypeFromProperties_fn, _getRefAlias, getRefAlias_fn, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn;
|
54
|
+
var _usedAliasNames, _caseOptions, _getTypeFromSchema, getTypeFromSchema_fn, _getTypeFromProperties, getTypeFromProperties_fn, _getRefAlias, getRefAlias_fn, _getParsedSchema, getParsedSchema_fn, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn;
|
55
55
|
var TypeGenerator = class extends core.SchemaGenerator {
|
56
|
-
constructor(options
|
57
|
-
usedEnumNames: {},
|
58
|
-
withJSDocs: true,
|
59
|
-
resolveName: ({ name }) => name,
|
60
|
-
enumType: "asConst",
|
61
|
-
dateType: "string",
|
62
|
-
optionalType: "questionToken"
|
63
|
-
}) {
|
56
|
+
constructor(options) {
|
64
57
|
super(options);
|
65
58
|
/**
|
66
59
|
* Creates a type node from a given schema.
|
@@ -76,6 +69,7 @@ var TypeGenerator = class extends core.SchemaGenerator {
|
|
76
69
|
* Create a type alias for the schema referenced by the given ReferenceObject
|
77
70
|
*/
|
78
71
|
__privateAdd(this, _getRefAlias);
|
72
|
+
__privateAdd(this, _getParsedSchema);
|
79
73
|
/**
|
80
74
|
* This is the very core of the OpenAPI to TS conversion - it takes a
|
81
75
|
* schema and returns the appropriate type.
|
@@ -147,7 +141,7 @@ getTypeFromProperties_fn = function(baseSchema, baseName) {
|
|
147
141
|
const additionalProperties = baseSchema?.additionalProperties;
|
148
142
|
const members = Object.keys(properties).map((name) => {
|
149
143
|
const schema = properties[name];
|
150
|
-
const isRequired = required
|
144
|
+
const isRequired = Array.isArray(required) ? required.includes(name) : !!required;
|
151
145
|
let type = __privateMethod(this, _getTypeFromSchema, getTypeFromSchema_fn).call(this, schema, this.options.resolveName({ name: `${baseName || ""} ${name}` }));
|
152
146
|
if (!type) {
|
153
147
|
return null;
|
@@ -166,7 +160,7 @@ getTypeFromProperties_fn = function(baseSchema, baseName) {
|
|
166
160
|
node: propertySignature,
|
167
161
|
comments: [
|
168
162
|
schema.description ? `@description ${schema.description}` : void 0,
|
169
|
-
schema.type ? `@type ${schema.type}${isRequired ? "" : " | undefined"} ${schema.format || ""}` : void 0,
|
163
|
+
schema.type ? `@type ${schema.type?.toString()}${isRequired ? "" : " | undefined"} ${schema.format || ""}` : void 0,
|
170
164
|
schema.example ? `@example ${schema.example}` : void 0,
|
171
165
|
schema.deprecated ? `@deprecated` : void 0,
|
172
166
|
schema.default !== void 0 && typeof schema.default === "string" ? `@default '${schema.default}'` : void 0,
|
@@ -199,8 +193,14 @@ getRefAlias_fn = function(obj, _baseName) {
|
|
199
193
|
};
|
200
194
|
return factory__namespace.createTypeReferenceNode(ref.propertyName, void 0);
|
201
195
|
};
|
196
|
+
_getParsedSchema = new WeakSet();
|
197
|
+
getParsedSchema_fn = function(schema) {
|
198
|
+
const parsedSchema = utils$1.getSchemaFactory(this.options.oas)(schema);
|
199
|
+
return parsedSchema;
|
200
|
+
};
|
202
201
|
_getBaseTypeFromSchema = new WeakSet();
|
203
|
-
getBaseTypeFromSchema_fn = function(
|
202
|
+
getBaseTypeFromSchema_fn = function(_schema, baseName) {
|
203
|
+
const { schema, version } = __privateMethod(this, _getParsedSchema, getParsedSchema_fn).call(this, _schema);
|
204
204
|
if (!schema) {
|
205
205
|
return factory__namespace.keywordTypeNodes.any;
|
206
206
|
}
|
@@ -212,7 +212,7 @@ getBaseTypeFromSchema_fn = function(schema, baseName) {
|
|
212
212
|
const union = factory__namespace.createUnionDeclaration({
|
213
213
|
withParentheses: true,
|
214
214
|
nodes: schema.oneOf.map((item) => {
|
215
|
-
return __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
|
215
|
+
return item && __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
|
216
216
|
}).filter((item) => {
|
217
217
|
return item && item !== factory__namespace.keywordTypeNodes.any;
|
218
218
|
})
|
@@ -229,7 +229,7 @@ getBaseTypeFromSchema_fn = function(schema, baseName) {
|
|
229
229
|
const union = factory__namespace.createUnionDeclaration({
|
230
230
|
withParentheses: true,
|
231
231
|
nodes: schema.anyOf.map((item) => {
|
232
|
-
return __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
|
232
|
+
return item && __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
|
233
233
|
}).filter((item) => {
|
234
234
|
return item && item !== factory__namespace.keywordTypeNodes.any;
|
235
235
|
})
|
@@ -246,7 +246,7 @@ getBaseTypeFromSchema_fn = function(schema, baseName) {
|
|
246
246
|
const and = factory__namespace.createIntersectionDeclaration({
|
247
247
|
withParentheses: true,
|
248
248
|
nodes: schema.allOf.map((item) => {
|
249
|
-
return __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
|
249
|
+
return item && __privateMethod(this, _getBaseTypeFromSchema, getBaseTypeFromSchema_fn).call(this, item);
|
250
250
|
}).filter((item) => {
|
251
251
|
return item && item !== factory__namespace.keywordTypeNodes.any;
|
252
252
|
})
|
@@ -323,7 +323,7 @@ getBaseTypeFromSchema_fn = function(schema, baseName) {
|
|
323
323
|
if (schema.format === "binary") {
|
324
324
|
return factory__namespace.createTypeReferenceNode("Blob", []);
|
325
325
|
}
|
326
|
-
if (
|
326
|
+
if (version === "3.1" && typeof schema["const"] === "string") {
|
327
327
|
return factory__namespace.createLiteralTypeNode(factory__namespace.createStringLiteral(schema["const"]));
|
328
328
|
}
|
329
329
|
return factory__namespace.keywordTypeNodes.any;
|
@@ -349,7 +349,8 @@ var TypeBuilder = class extends swagger.OasBuilder {
|
|
349
349
|
resolveName: this.options.resolveName,
|
350
350
|
enumType: this.options.enumType,
|
351
351
|
dateType: this.options.dateType,
|
352
|
-
optionalType: this.options.optionalType
|
352
|
+
optionalType: this.options.optionalType,
|
353
|
+
oas: this.options.oas
|
353
354
|
});
|
354
355
|
const sources = generator.build({
|
355
356
|
schema: operationSchema.schema,
|
@@ -405,7 +406,7 @@ var OperationGenerator = class extends swagger.OperationGenerator {
|
|
405
406
|
}
|
406
407
|
async get(operation, schemas, options) {
|
407
408
|
const { mode, enumType, dateType, optionalType, usedEnumNames } = options;
|
408
|
-
const { pluginManager, plugin } = this.context;
|
409
|
+
const { pluginManager, plugin, oas } = this.context;
|
409
410
|
const type = this.resolve(operation);
|
410
411
|
const fileResolver = (name) => {
|
411
412
|
const root = pluginManager.resolvePath({ baseName: type.baseName, pluginKey: plugin?.key, options: { tag: operation.getTags()[0]?.name } });
|
@@ -422,7 +423,8 @@ var OperationGenerator = class extends swagger.OperationGenerator {
|
|
422
423
|
resolveName: (params) => pluginManager.resolveName({ ...params, pluginKey: plugin?.key }),
|
423
424
|
enumType,
|
424
425
|
optionalType,
|
425
|
-
dateType
|
426
|
+
dateType,
|
427
|
+
oas
|
426
428
|
}).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.errors).configure().print();
|
427
429
|
const combinedSchemaSource = __privateMethod(this, _printCombinedSchema, printCombinedSchema_fn).call(this, type.name, operation, schemas);
|
428
430
|
return {
|
@@ -437,7 +439,7 @@ var OperationGenerator = class extends swagger.OperationGenerator {
|
|
437
439
|
}
|
438
440
|
async post(operation, schemas, options) {
|
439
441
|
const { mode, enumType, dateType, optionalType, usedEnumNames } = options;
|
440
|
-
const { pluginManager, plugin } = this.context;
|
442
|
+
const { pluginManager, plugin, oas } = this.context;
|
441
443
|
const type = this.resolve(operation);
|
442
444
|
const fileResolver = (name) => {
|
443
445
|
const root = pluginManager.resolvePath({ baseName: type.baseName, pluginKey: plugin?.key, options: { tag: operation.getTags()[0]?.name } });
|
@@ -454,7 +456,8 @@ var OperationGenerator = class extends swagger.OperationGenerator {
|
|
454
456
|
resolveName: (params) => pluginManager.resolveName({ ...params, pluginKey: plugin?.key }),
|
455
457
|
enumType,
|
456
458
|
optionalType,
|
457
|
-
dateType
|
459
|
+
dateType,
|
460
|
+
oas
|
458
461
|
}).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.request).add(schemas.response).add(schemas.errors).configure().print();
|
459
462
|
const combinedSchemaSource = __privateMethod(this, _printCombinedSchema, printCombinedSchema_fn).call(this, type.name, operation, schemas);
|
460
463
|
return {
|
@@ -538,7 +541,7 @@ printCombinedSchema_fn = function(name, operation, schemas) {
|
|
538
541
|
|
539
542
|
// src/plugin.ts
|
540
543
|
var pluginName = "swagger-ts";
|
541
|
-
var pluginKey = [
|
544
|
+
var pluginKey = [pluginName];
|
542
545
|
var definePlugin = core.createPlugin((options) => {
|
543
546
|
const {
|
544
547
|
output = "types",
|
@@ -553,15 +556,10 @@ var definePlugin = core.createPlugin((options) => {
|
|
553
556
|
exportAs
|
554
557
|
} = options;
|
555
558
|
const template = group?.output ? group.output : `${output}/{{tag}}Controller`;
|
556
|
-
let pluginsOptions;
|
557
559
|
return {
|
558
560
|
name: pluginName,
|
559
561
|
options,
|
560
|
-
|
561
|
-
validate(plugins) {
|
562
|
-
pluginsOptions = core.PluginManager.getDependedPlugins(plugins, [swagger.pluginName]);
|
563
|
-
return true;
|
564
|
-
},
|
562
|
+
pre: [swagger.pluginName],
|
565
563
|
resolvePath(baseName, directory, options2) {
|
566
564
|
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
567
565
|
const mode = core.FileManager.getMode(path__default.default.resolve(root, output));
|
@@ -588,7 +586,7 @@ var definePlugin = core.createPlugin((options) => {
|
|
588
586
|
return this.fileManager.write(source, writePath);
|
589
587
|
},
|
590
588
|
async buildStart() {
|
591
|
-
const [swaggerPlugin] =
|
589
|
+
const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [swagger.pluginName]);
|
592
590
|
const oas = await swaggerPlugin.api.getOas();
|
593
591
|
const schemas = await swaggerPlugin.api.getSchemas();
|
594
592
|
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
@@ -609,7 +607,8 @@ var definePlugin = core.createPlugin((options) => {
|
|
609
607
|
withJSDocs: true,
|
610
608
|
enumType,
|
611
609
|
dateType,
|
612
|
-
optionalType
|
610
|
+
optionalType,
|
611
|
+
oas
|
613
612
|
}).configure();
|
614
613
|
Object.entries(schemas).forEach(([name, schema]) => {
|
615
614
|
return builder.add({
|
@@ -641,7 +640,8 @@ var definePlugin = core.createPlugin((options) => {
|
|
641
640
|
withJSDocs: true,
|
642
641
|
enumType,
|
643
642
|
dateType,
|
644
|
-
optionalType
|
643
|
+
optionalType,
|
644
|
+
oas
|
645
645
|
}).configure();
|
646
646
|
Object.entries(schemas).forEach(([name, schema]) => {
|
647
647
|
return builder.add({
|
package/dist/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
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,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,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AAI;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;;;AI/ND,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, 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 }).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 { definePlugin } from './plugin.ts'\n\nexport { definePlugin, pluginKey, pluginName } from './plugin.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,QAAmB,CAAC;AAC1B,UAAM,OAAO,sBAAK,0CAAL,WAAwB,QAAQ;AAE7C,QAAI,CAAC,MAAM;AACT,aAAO,KAAK;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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;;;AI3ND,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'] = [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\n return {\n name: pluginName,\n options,\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))\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]: [KubbPlugin<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))\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/dist/index.d.cts
CHANGED
@@ -72,7 +72,7 @@ type FileMeta = {
|
|
72
72
|
name?: string;
|
73
73
|
tag?: string;
|
74
74
|
};
|
75
|
-
type PluginOptions = PluginFactoryOptions<'swagger-ts',
|
75
|
+
type PluginOptions = PluginFactoryOptions<'swagger-ts', Options, Options, never, ResolvePathOptions>;
|
76
76
|
declare module '@kubb/core' {
|
77
77
|
interface _Register {
|
78
78
|
['@kubb/swagger-ts']: PluginOptions;
|
@@ -83,4 +83,4 @@ declare const pluginName = "swagger-ts";
|
|
83
83
|
declare const pluginKey: PluginOptions['key'];
|
84
84
|
declare const definePlugin: (options: Options) => _kubb_core.KubbUserPluginWithLifeCycle<PluginOptions>;
|
85
85
|
|
86
|
-
export { FileMeta, Options, PluginOptions, definePlugin as default, definePlugin, pluginKey, pluginName };
|
86
|
+
export { type FileMeta, type Options, type PluginOptions, definePlugin as default, definePlugin, pluginKey, pluginName };
|
package/dist/index.d.ts
CHANGED
@@ -72,7 +72,7 @@ type FileMeta = {
|
|
72
72
|
name?: string;
|
73
73
|
tag?: string;
|
74
74
|
};
|
75
|
-
type PluginOptions = PluginFactoryOptions<'swagger-ts',
|
75
|
+
type PluginOptions = PluginFactoryOptions<'swagger-ts', Options, Options, never, ResolvePathOptions>;
|
76
76
|
declare module '@kubb/core' {
|
77
77
|
interface _Register {
|
78
78
|
['@kubb/swagger-ts']: PluginOptions;
|
@@ -83,4 +83,4 @@ declare const pluginName = "swagger-ts";
|
|
83
83
|
declare const pluginKey: PluginOptions['key'];
|
84
84
|
declare const definePlugin: (options: Options) => _kubb_core.KubbUserPluginWithLifeCycle<PluginOptions>;
|
85
85
|
|
86
|
-
export { FileMeta, Options, PluginOptions, definePlugin as default, definePlugin, pluginKey, pluginName };
|
86
|
+
export { type FileMeta, type Options, type PluginOptions, definePlugin as default, definePlugin, pluginKey, pluginName };
|