swagger-typescript-api 13.2.8 → 13.2.10
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/CHANGELOG.md +30 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/lib.cjs +3 -1
- package/dist/lib.d.cts +226 -11
- package/dist/lib.d.ts +226 -11
- package/dist/lib.js +2 -2
- package/dist/{src-BtVFSrff.cjs → src-C5bMYV9w.cjs} +130 -80
- package/dist/src-C5bMYV9w.cjs.map +1 -0
- package/dist/{src-4gUT3jPg.js → src-s8addnrG.js} +183 -152
- package/dist/src-s8addnrG.js.map +1 -0
- package/package.json +12 -12
- package/templates/base/http-clients/fetch-http-client.ejs +1 -1
- package/dist/src-4gUT3jPg.js.map +0 -1
- package/dist/src-BtVFSrff.cjs.map +0 -1
|
@@ -35,6 +35,7 @@ const __biomejs_js_api = __toESM(require("@biomejs/js-api"));
|
|
|
35
35
|
const nanoid = __toESM(require("nanoid"));
|
|
36
36
|
const js_yaml = __toESM(require("js-yaml"));
|
|
37
37
|
const swagger2openapi = __toESM(require("swagger2openapi"));
|
|
38
|
+
const node_module = __toESM(require("node:module"));
|
|
38
39
|
const node_url = __toESM(require("node:url"));
|
|
39
40
|
const eta = __toESM(require("eta"));
|
|
40
41
|
const node_fs = __toESM(require("node:fs"));
|
|
@@ -181,7 +182,7 @@ const getRandomInt = (min = 0, max = 1) => {
|
|
|
181
182
|
var ComponentTypeNameResolver = class extends NameResolver {
|
|
182
183
|
counter = 1;
|
|
183
184
|
fallbackNameCounter = 1;
|
|
184
|
-
countersByVariant = new Map();
|
|
185
|
+
countersByVariant = /* @__PURE__ */ new Map();
|
|
185
186
|
constructor(config, reservedNames) {
|
|
186
187
|
super(config, reservedNames, (variants) => {
|
|
187
188
|
const randomVariant = variants[getRandomInt(0, variants.length - 1)];
|
|
@@ -203,7 +204,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
203
204
|
//#endregion
|
|
204
205
|
//#region package.json
|
|
205
206
|
var name = "swagger-typescript-api";
|
|
206
|
-
var version = "13.2.
|
|
207
|
+
var version = "13.2.10";
|
|
207
208
|
var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
|
|
208
209
|
var homepage = "https://github.com/acacode/swagger-typescript-api";
|
|
209
210
|
var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
|
|
@@ -243,10 +244,10 @@ var scripts = {
|
|
|
243
244
|
"typedoc": "typedoc"
|
|
244
245
|
};
|
|
245
246
|
var dependencies = {
|
|
246
|
-
"@biomejs/js-api": "
|
|
247
|
-
"@biomejs/wasm-nodejs": "2.
|
|
247
|
+
"@biomejs/js-api": "3.0.0",
|
|
248
|
+
"@biomejs/wasm-nodejs": "2.2.4",
|
|
248
249
|
"@types/swagger-schema-official": "^2.0.25",
|
|
249
|
-
"c12": "^3.0
|
|
250
|
+
"c12": "^3.2.0",
|
|
250
251
|
"citty": "^0.1.6",
|
|
251
252
|
"consola": "^3.4.2",
|
|
252
253
|
"eta": "^2.2.0",
|
|
@@ -258,22 +259,22 @@ var dependencies = {
|
|
|
258
259
|
"typescript": "~5.9.2"
|
|
259
260
|
};
|
|
260
261
|
var devDependencies = {
|
|
261
|
-
"@biomejs/biome": "2.
|
|
262
|
+
"@biomejs/biome": "2.2.4",
|
|
262
263
|
"@changesets/changelog-github": "0.5.1",
|
|
263
|
-
"@changesets/cli": "2.29.
|
|
264
|
-
"@tsconfig/
|
|
264
|
+
"@changesets/cli": "2.29.7",
|
|
265
|
+
"@tsconfig/node20": "20.1.6",
|
|
265
266
|
"@tsconfig/strictest": "2.0.5",
|
|
266
267
|
"@types/js-yaml": "4.0.9",
|
|
267
268
|
"@types/lodash": "4.17.20",
|
|
268
|
-
"@types/node": "24.2
|
|
269
|
+
"@types/node": "24.3.2",
|
|
269
270
|
"@types/swagger2openapi": "7.0.4",
|
|
270
|
-
"axios": "1.
|
|
271
|
+
"axios": "1.12.1",
|
|
271
272
|
"openapi-types": "12.1.3",
|
|
272
|
-
"tsdown": "0.
|
|
273
|
-
"typedoc": "0.28.
|
|
273
|
+
"tsdown": "0.15.1",
|
|
274
|
+
"typedoc": "0.28.12",
|
|
274
275
|
"vitest": "3.2.4"
|
|
275
276
|
};
|
|
276
|
-
var packageManager = "yarn@4.9.
|
|
277
|
+
var packageManager = "yarn@4.9.4";
|
|
277
278
|
var engines = { "node": ">=20" };
|
|
278
279
|
var publishConfig = {
|
|
279
280
|
"access": "public",
|
|
@@ -323,7 +324,7 @@ __export(constants_exports, {
|
|
|
323
324
|
RESERVED_PATH_ARG_NAMES: () => RESERVED_PATH_ARG_NAMES,
|
|
324
325
|
RESERVED_QUERY_ARG_NAMES: () => RESERVED_QUERY_ARG_NAMES,
|
|
325
326
|
RESERVED_REQ_PARAMS_ARG_NAMES: () => RESERVED_REQ_PARAMS_ARG_NAMES,
|
|
326
|
-
SCHEMA_TYPES: () => SCHEMA_TYPES
|
|
327
|
+
SCHEMA_TYPES: () => SCHEMA_TYPES$1
|
|
327
328
|
});
|
|
328
329
|
const DEFAULT_BODY_ARG_NAME = "data";
|
|
329
330
|
const FILE_PREFIX = `/* eslint-disable */
|
|
@@ -362,7 +363,7 @@ const RESERVED_REQ_PARAMS_ARG_NAMES = [
|
|
|
362
363
|
"reqParams",
|
|
363
364
|
"httpParams"
|
|
364
365
|
];
|
|
365
|
-
const SCHEMA_TYPES = {
|
|
366
|
+
const SCHEMA_TYPES$1 = {
|
|
366
367
|
ARRAY: "array",
|
|
367
368
|
OBJECT: "object",
|
|
368
369
|
ENUM: "enum",
|
|
@@ -452,7 +453,7 @@ var CodeGenConfig = class {
|
|
|
452
453
|
httpClient: "http-client",
|
|
453
454
|
outOfModuleApi: "Common"
|
|
454
455
|
};
|
|
455
|
-
routeNameDuplicatesMap = new Map();
|
|
456
|
+
routeNameDuplicatesMap = /* @__PURE__ */ new Map();
|
|
456
457
|
hooks = {
|
|
457
458
|
onPreBuildRoutePath: (_routePath) => void 0,
|
|
458
459
|
onBuildRoutePath: (_routeData) => void 0,
|
|
@@ -719,6 +720,7 @@ var CodeGenConfig = class {
|
|
|
719
720
|
}
|
|
720
721
|
update = (update) => {
|
|
721
722
|
objectAssign(this, update);
|
|
723
|
+
if (this.enumNamesAsValues) this.extractEnums = true;
|
|
722
724
|
};
|
|
723
725
|
};
|
|
724
726
|
|
|
@@ -786,7 +788,7 @@ var SchemaFormatters = class {
|
|
|
786
788
|
this.templatesWorker = schemaParser.templatesWorker;
|
|
787
789
|
}
|
|
788
790
|
base = {
|
|
789
|
-
[SCHEMA_TYPES.ENUM]: (parsedSchema) => {
|
|
791
|
+
[SCHEMA_TYPES$1.ENUM]: (parsedSchema) => {
|
|
790
792
|
if (this.config.generateUnionEnums) return {
|
|
791
793
|
...parsedSchema,
|
|
792
794
|
$content: parsedSchema.content,
|
|
@@ -798,15 +800,15 @@ var SchemaFormatters = class {
|
|
|
798
800
|
content: this.config.Ts.EnumFieldsWrapper(parsedSchema.content)
|
|
799
801
|
};
|
|
800
802
|
},
|
|
801
|
-
[SCHEMA_TYPES.OBJECT]: (parsedSchema) => {
|
|
802
|
-
if (parsedSchema.nullable) return this.inline[SCHEMA_TYPES.OBJECT](parsedSchema);
|
|
803
|
+
[SCHEMA_TYPES$1.OBJECT]: (parsedSchema) => {
|
|
804
|
+
if (parsedSchema.nullable) return this.inline[SCHEMA_TYPES$1.OBJECT](parsedSchema);
|
|
803
805
|
return {
|
|
804
806
|
...parsedSchema,
|
|
805
807
|
$content: parsedSchema.content,
|
|
806
808
|
content: this.formatObjectContent(parsedSchema.content)
|
|
807
809
|
};
|
|
808
810
|
},
|
|
809
|
-
[SCHEMA_TYPES.PRIMITIVE]: (parsedSchema) => {
|
|
811
|
+
[SCHEMA_TYPES$1.PRIMITIVE]: (parsedSchema) => {
|
|
810
812
|
return {
|
|
811
813
|
...parsedSchema,
|
|
812
814
|
$content: parsedSchema.content
|
|
@@ -814,13 +816,13 @@ var SchemaFormatters = class {
|
|
|
814
816
|
}
|
|
815
817
|
};
|
|
816
818
|
inline = {
|
|
817
|
-
[SCHEMA_TYPES.ENUM]: (parsedSchema) => {
|
|
819
|
+
[SCHEMA_TYPES$1.ENUM]: (parsedSchema) => {
|
|
818
820
|
return {
|
|
819
821
|
...parsedSchema,
|
|
820
822
|
content: parsedSchema.$ref ? parsedSchema.typeName : this.config.Ts.UnionType(lodash.default.compact([...parsedSchema.content.map(({ value }) => `${value}`), parsedSchema.nullable && this.config.Ts.Keyword.Null])) || this.config.Ts.Keyword.Any
|
|
821
823
|
};
|
|
822
824
|
},
|
|
823
|
-
[SCHEMA_TYPES.OBJECT]: (parsedSchema) => {
|
|
825
|
+
[SCHEMA_TYPES$1.OBJECT]: (parsedSchema) => {
|
|
824
826
|
if (typeof parsedSchema.content === "string") return {
|
|
825
827
|
...parsedSchema,
|
|
826
828
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
@@ -906,7 +908,7 @@ var ArraySchemaParser = class extends MonoSchemaParser {
|
|
|
906
908
|
parse() {
|
|
907
909
|
let contentType;
|
|
908
910
|
const { type: type$1, description: description$1, items } = this.schema || {};
|
|
909
|
-
if (Array.isArray(items) && type$1 === SCHEMA_TYPES.ARRAY) {
|
|
911
|
+
if (Array.isArray(items) && type$1 === SCHEMA_TYPES$1.ARRAY) {
|
|
910
912
|
const tupleContent = [];
|
|
911
913
|
for (const item of items) tupleContent.push(this.schemaParserFabric.createSchemaParser({
|
|
912
914
|
schema: item,
|
|
@@ -924,8 +926,8 @@ var ArraySchemaParser = class extends MonoSchemaParser {
|
|
|
924
926
|
...typeof this.schema === "object" ? this.schema : {},
|
|
925
927
|
$schemaPath: this.schemaPath.slice(),
|
|
926
928
|
$parsedSchema: true,
|
|
927
|
-
schemaType: SCHEMA_TYPES.PRIMITIVE,
|
|
928
|
-
type: SCHEMA_TYPES.PRIMITIVE,
|
|
929
|
+
schemaType: SCHEMA_TYPES$1.PRIMITIVE,
|
|
930
|
+
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
929
931
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
930
932
|
name: this.typeName,
|
|
931
933
|
description: this.schemaFormatters.formatDescription(description$1),
|
|
@@ -945,12 +947,12 @@ var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
|
945
947
|
...typeof this.schema === "object" ? this.schema : {},
|
|
946
948
|
$schemaPath: this.schemaPath.slice(),
|
|
947
949
|
$parsedSchema: true,
|
|
948
|
-
schemaType: SCHEMA_TYPES.COMPLEX,
|
|
949
|
-
type: SCHEMA_TYPES.PRIMITIVE,
|
|
950
|
+
schemaType: SCHEMA_TYPES$1.COMPLEX,
|
|
951
|
+
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
950
952
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
951
953
|
name: this.typeName,
|
|
952
954
|
description: this.schemaFormatters.formatDescription(this.schema.description || lodash.default.compact(lodash.default.map(this.schema[complexType], "description"))[0] || ""),
|
|
953
|
-
content: this.config.Ts.IntersectionType(lodash.default.compact([this.config.Ts.ExpressionGroup(complexSchemaContent), this.schemaUtils.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES.OBJECT && this.config.Ts.ExpressionGroup(this.schemaParserFabric.createSchemaParser({
|
|
955
|
+
content: this.config.Ts.IntersectionType(lodash.default.compact([this.config.Ts.ExpressionGroup(complexSchemaContent), this.schemaUtils.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES$1.OBJECT && this.config.Ts.ExpressionGroup(this.schemaParserFabric.createSchemaParser({
|
|
954
956
|
schema: simpleSchema,
|
|
955
957
|
schemaPath: this.schemaPath
|
|
956
958
|
}).getInlineParseContent())])) || this.config.Ts.Keyword.Any
|
|
@@ -980,8 +982,8 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
980
982
|
...typeof this.schema === "object" ? this.schema : {},
|
|
981
983
|
$schemaPath: this.schemaPath.slice(),
|
|
982
984
|
$parsedSchema: true,
|
|
983
|
-
schemaType: SCHEMA_TYPES.COMPLEX,
|
|
984
|
-
type: SCHEMA_TYPES.PRIMITIVE,
|
|
985
|
+
schemaType: SCHEMA_TYPES$1.COMPLEX,
|
|
986
|
+
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
985
987
|
typeIdentifier: ts.Keyword.Type,
|
|
986
988
|
name: this.typeName,
|
|
987
989
|
description: this.schemaFormatters.formatDescription(this.schema.description),
|
|
@@ -1060,7 +1062,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1060
1062
|
let mappingPropertySchemaEnumKeysMap = {};
|
|
1061
1063
|
let mappingPropertySchema = lodash.default.get(abstractSchemaStruct?.component?.rawTypeData, ["properties", discPropertyName]);
|
|
1062
1064
|
if (this.schemaUtils.isRefSchema(mappingPropertySchema)) mappingPropertySchema = this.schemaUtils.getSchemaRefType(mappingPropertySchema);
|
|
1063
|
-
if (mappingPropertySchema?.rawTypeData?.$parsed?.type === SCHEMA_TYPES.ENUM) mappingPropertySchemaEnumKeysMap = lodash.default.reduce(mappingPropertySchema.rawTypeData.$parsed.enum, (acc, key, index) => {
|
|
1065
|
+
if (mappingPropertySchema?.rawTypeData?.$parsed?.type === SCHEMA_TYPES$1.ENUM) mappingPropertySchemaEnumKeysMap = lodash.default.reduce(mappingPropertySchema.rawTypeData.$parsed.enum, (acc, key, index) => {
|
|
1064
1066
|
const enumKey = mappingPropertySchema.rawTypeData.$parsed.content[index].key;
|
|
1065
1067
|
acc[key] = ts.EnumUsageKey(mappingPropertySchema.rawTypeData.$parsed.typeName, enumKey);
|
|
1066
1068
|
return acc;
|
|
@@ -1077,9 +1079,9 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1077
1079
|
...schema,
|
|
1078
1080
|
$ref: abstractSchemaStruct.component.$ref
|
|
1079
1081
|
};
|
|
1080
|
-
if (this.schemaUtils.getInternalSchemaType(schema) === SCHEMA_TYPES.OBJECT) for (const schemaPropertyName in schema.properties) {
|
|
1082
|
+
if (this.schemaUtils.getInternalSchemaType(schema) === SCHEMA_TYPES$1.OBJECT) for (const schemaPropertyName in schema.properties) {
|
|
1081
1083
|
const schemaProperty = schema.properties[schemaPropertyName];
|
|
1082
|
-
if (schemaPropertyName === discPropertyName && this.schemaUtils.getInternalSchemaType(schemaProperty) === SCHEMA_TYPES.ENUM && schemaProperty.enum.length === 1 && mappingPropertySchemaEnumKeysMap[schemaProperty.enum[0]]) schema.properties[schemaPropertyName] = this.schemaParserFabric.createSchema({ content: mappingPropertySchemaEnumKeysMap[schemaProperty.enum[0]] });
|
|
1084
|
+
if (schemaPropertyName === discPropertyName && this.schemaUtils.getInternalSchemaType(schemaProperty) === SCHEMA_TYPES$1.ENUM && schemaProperty.enum.length === 1 && mappingPropertySchemaEnumKeysMap[schemaProperty.enum[0]]) schema.properties[schemaPropertyName] = this.schemaParserFabric.createSchema({ content: mappingPropertySchemaEnumKeysMap[schemaProperty.enum[0]] });
|
|
1083
1085
|
}
|
|
1084
1086
|
return schema;
|
|
1085
1087
|
});
|
|
@@ -1118,7 +1120,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1118
1120
|
createComplexSchemaStruct = () => {
|
|
1119
1121
|
const ts = this.config.Ts;
|
|
1120
1122
|
const complexType = this.schemaUtils.getComplexType(this.schema);
|
|
1121
|
-
if (complexType === SCHEMA_TYPES.COMPLEX_UNKNOWN) return null;
|
|
1123
|
+
if (complexType === SCHEMA_TYPES$1.COMPLEX_UNKNOWN) return null;
|
|
1122
1124
|
return { content: ts.ExpressionGroup(this.schemaParser._complexSchemaParsers[complexType](this.schema)) };
|
|
1123
1125
|
};
|
|
1124
1126
|
};
|
|
@@ -1175,9 +1177,19 @@ var EnumSchemaParser = class extends MonoSchemaParser {
|
|
|
1175
1177
|
let content = null;
|
|
1176
1178
|
const formatValue = (value) => {
|
|
1177
1179
|
if (value === null) return this.config.Ts.NullValue(value);
|
|
1178
|
-
if (keyType.includes(this.schemaUtils.getSchemaType({ type: "number" })))
|
|
1179
|
-
|
|
1180
|
-
|
|
1180
|
+
if (keyType.includes(this.schemaUtils.getSchemaType({ type: "number" }))) {
|
|
1181
|
+
const maybeNumber = typeof value === "number" ? value : Number(value);
|
|
1182
|
+
if (!Number.isNaN(maybeNumber)) return this.config.Ts.NumberValue(maybeNumber);
|
|
1183
|
+
}
|
|
1184
|
+
if (keyType.includes(this.schemaUtils.getSchemaType({ type: "boolean" }))) {
|
|
1185
|
+
if (typeof value === "boolean") return this.config.Ts.BooleanValue(value);
|
|
1186
|
+
if (value === "true" || value === "false") return this.config.Ts.BooleanValue(value === "true");
|
|
1187
|
+
}
|
|
1188
|
+
switch (typeof value) {
|
|
1189
|
+
case "number": return this.config.Ts.NumberValue(value);
|
|
1190
|
+
case "boolean": return this.config.Ts.BooleanValue(value);
|
|
1191
|
+
default: return this.config.Ts.StringValue(value);
|
|
1192
|
+
}
|
|
1181
1193
|
};
|
|
1182
1194
|
if (Array.isArray(enumNames) && lodash.default.size(enumNames)) content = enumNames.map((enumName, index) => {
|
|
1183
1195
|
const enumValue = lodash.default.get(this.schema.enum, index);
|
|
@@ -1211,8 +1223,8 @@ var EnumSchemaParser = class extends MonoSchemaParser {
|
|
|
1211
1223
|
$ref,
|
|
1212
1224
|
typeName: this.typeName || $ref && refType.typeName || null,
|
|
1213
1225
|
$parsedSchema: true,
|
|
1214
|
-
schemaType: SCHEMA_TYPES.ENUM,
|
|
1215
|
-
type: SCHEMA_TYPES.ENUM,
|
|
1226
|
+
schemaType: SCHEMA_TYPES$1.ENUM,
|
|
1227
|
+
type: SCHEMA_TYPES$1.ENUM,
|
|
1216
1228
|
keyType,
|
|
1217
1229
|
typeIdentifier: this.config.generateUnionEnums ? this.config.Ts.Keyword.Type : this.config.Ts.Keyword.Enum,
|
|
1218
1230
|
name: this.typeName,
|
|
@@ -1237,8 +1249,8 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
|
|
|
1237
1249
|
...typeof this.schema === "object" ? this.schema : {},
|
|
1238
1250
|
$schemaPath: this.schemaPath.slice(),
|
|
1239
1251
|
$parsedSchema: true,
|
|
1240
|
-
schemaType: SCHEMA_TYPES.OBJECT,
|
|
1241
|
-
type: SCHEMA_TYPES.OBJECT,
|
|
1252
|
+
schemaType: SCHEMA_TYPES$1.OBJECT,
|
|
1253
|
+
type: SCHEMA_TYPES$1.OBJECT,
|
|
1242
1254
|
typeIdentifier: this.config.Ts.Keyword.Interface,
|
|
1243
1255
|
name: this.typeName,
|
|
1244
1256
|
description: this.schemaFormatters.formatDescription(this.schema.description),
|
|
@@ -1320,7 +1332,7 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
|
1320
1332
|
...typeof this.schema === "object" ? this.schema : {},
|
|
1321
1333
|
oneOf: type$1.map((type$2) => ({ type: type$2 }))
|
|
1322
1334
|
});
|
|
1323
|
-
if (Array.isArray(items) && type$1 === SCHEMA_TYPES.ARRAY) contentType = this.config.Ts.Tuple(items.map((item) => this.schemaParserFabric.createSchemaParser({
|
|
1335
|
+
if (Array.isArray(items) && type$1 === SCHEMA_TYPES$1.ARRAY) contentType = this.config.Ts.Tuple(items.map((item) => this.schemaParserFabric.createSchemaParser({
|
|
1324
1336
|
schema: item,
|
|
1325
1337
|
schemaPath: this.schemaPath
|
|
1326
1338
|
}).getInlineParseContent()));
|
|
@@ -1328,8 +1340,8 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
|
1328
1340
|
...typeof this.schema === "object" ? this.schema : {},
|
|
1329
1341
|
$schemaPath: this.schemaPath.slice(),
|
|
1330
1342
|
$parsedSchema: true,
|
|
1331
|
-
schemaType: SCHEMA_TYPES.PRIMITIVE,
|
|
1332
|
-
type: SCHEMA_TYPES.PRIMITIVE,
|
|
1343
|
+
schemaType: SCHEMA_TYPES$1.PRIMITIVE,
|
|
1344
|
+
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
1333
1345
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
1334
1346
|
name: this.typeName,
|
|
1335
1347
|
description: this.schemaFormatters.formatDescription(description$1),
|
|
@@ -1410,67 +1422,67 @@ var SchemaParser = class {
|
|
|
1410
1422
|
this.schemaPath = [...schemaPath || []];
|
|
1411
1423
|
}
|
|
1412
1424
|
_complexSchemaParsers = {
|
|
1413
|
-
[SCHEMA_TYPES.COMPLEX_ONE_OF]: (schema) => {
|
|
1425
|
+
[SCHEMA_TYPES$1.COMPLEX_ONE_OF]: (schema) => {
|
|
1414
1426
|
const SchemaParser$1 = this.config.schemaParsers.complexOneOf || OneOfSchemaParser;
|
|
1415
1427
|
const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
|
|
1416
1428
|
return schemaParser.parse();
|
|
1417
1429
|
},
|
|
1418
|
-
[SCHEMA_TYPES.COMPLEX_ALL_OF]: (schema) => {
|
|
1430
|
+
[SCHEMA_TYPES$1.COMPLEX_ALL_OF]: (schema) => {
|
|
1419
1431
|
const SchemaParser$1 = this.config.schemaParsers.complexAllOf || AllOfSchemaParser;
|
|
1420
1432
|
const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
|
|
1421
1433
|
return schemaParser.parse();
|
|
1422
1434
|
},
|
|
1423
|
-
[SCHEMA_TYPES.COMPLEX_ANY_OF]: (schema) => {
|
|
1435
|
+
[SCHEMA_TYPES$1.COMPLEX_ANY_OF]: (schema) => {
|
|
1424
1436
|
const SchemaParser$1 = this.config.schemaParsers.complexAnyOf || AnyOfSchemaParser;
|
|
1425
1437
|
const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
|
|
1426
1438
|
return schemaParser.parse();
|
|
1427
1439
|
},
|
|
1428
|
-
[SCHEMA_TYPES.COMPLEX_NOT]: (schema) => {
|
|
1440
|
+
[SCHEMA_TYPES$1.COMPLEX_NOT]: (schema) => {
|
|
1429
1441
|
const SchemaParser$1 = this.config.schemaParsers.complexNot || NotSchemaParser;
|
|
1430
1442
|
const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
|
|
1431
1443
|
return schemaParser.parse();
|
|
1432
1444
|
}
|
|
1433
1445
|
};
|
|
1434
1446
|
_baseSchemaParsers = {
|
|
1435
|
-
[SCHEMA_TYPES.ENUM]: (schema, typeName) => {
|
|
1447
|
+
[SCHEMA_TYPES$1.ENUM]: (schema, typeName) => {
|
|
1436
1448
|
const SchemaParser$1 = this.config.schemaParsers.enum || EnumSchemaParser;
|
|
1437
1449
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1438
1450
|
return schemaParser.parse();
|
|
1439
1451
|
},
|
|
1440
|
-
[SCHEMA_TYPES.OBJECT]: (schema, typeName) => {
|
|
1452
|
+
[SCHEMA_TYPES$1.OBJECT]: (schema, typeName) => {
|
|
1441
1453
|
const SchemaParser$1 = this.config.schemaParsers.object || ObjectSchemaParser;
|
|
1442
1454
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1443
1455
|
return schemaParser.parse();
|
|
1444
1456
|
},
|
|
1445
|
-
[SCHEMA_TYPES.COMPLEX]: (schema, typeName) => {
|
|
1457
|
+
[SCHEMA_TYPES$1.COMPLEX]: (schema, typeName) => {
|
|
1446
1458
|
const SchemaParser$1 = this.config.schemaParsers.complex || ComplexSchemaParser;
|
|
1447
1459
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1448
1460
|
return schemaParser.parse();
|
|
1449
1461
|
},
|
|
1450
|
-
[SCHEMA_TYPES.PRIMITIVE]: (schema, typeName) => {
|
|
1462
|
+
[SCHEMA_TYPES$1.PRIMITIVE]: (schema, typeName) => {
|
|
1451
1463
|
const SchemaParser$1 = this.config.schemaParsers.primitive || PrimitiveSchemaParser;
|
|
1452
1464
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1453
1465
|
return schemaParser.parse();
|
|
1454
1466
|
},
|
|
1455
|
-
[SCHEMA_TYPES.DISCRIMINATOR]: (schema, typeName) => {
|
|
1467
|
+
[SCHEMA_TYPES$1.DISCRIMINATOR]: (schema, typeName) => {
|
|
1456
1468
|
const SchemaParser$1 = this.config.schemaParsers.discriminator || DiscriminatorSchemaParser;
|
|
1457
1469
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1458
1470
|
return schemaParser.parse();
|
|
1459
1471
|
},
|
|
1460
|
-
[SCHEMA_TYPES.ARRAY]: (schema, typeName) => {
|
|
1472
|
+
[SCHEMA_TYPES$1.ARRAY]: (schema, typeName) => {
|
|
1461
1473
|
const SchemaParser$1 = this.config.schemaParsers.array || ArraySchemaParser;
|
|
1462
1474
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1463
1475
|
return schemaParser.parse();
|
|
1464
1476
|
}
|
|
1465
1477
|
};
|
|
1466
1478
|
parseSchema = () => {
|
|
1467
|
-
if (!this.schema) return this._baseSchemaParsers[SCHEMA_TYPES.PRIMITIVE](null, this.typeName);
|
|
1479
|
+
if (!this.schema) return this._baseSchemaParsers[SCHEMA_TYPES$1.PRIMITIVE](null, this.typeName);
|
|
1468
1480
|
let schemaType = null;
|
|
1469
1481
|
let parsedSchema = null;
|
|
1470
1482
|
if (typeof this.schema === "string") return this.schema;
|
|
1471
1483
|
if (!this.schema.$parsed) {
|
|
1472
1484
|
if (!this.typeName && this.schemaUtils.isRefSchema(this.schema)) this.typeName = this.schemaUtils.getSchemaType(this.schema);
|
|
1473
|
-
if (this.schema.items && !Array.isArray(this.schema.items) && !this.schema.type) this.schema.type = SCHEMA_TYPES.ARRAY;
|
|
1485
|
+
if (this.schema.items && !Array.isArray(this.schema.items) && !this.schema.type) this.schema.type = SCHEMA_TYPES$1.ARRAY;
|
|
1474
1486
|
if (Array.isArray(this.schema.enum) && this.schema.enum.length === 1 && this.schema.enum[0] == null) {
|
|
1475
1487
|
consola.consola.debug("invalid enum schema", this.schema);
|
|
1476
1488
|
this.schema = { type: this.config.Ts.Keyword.Null };
|
|
@@ -1585,8 +1597,8 @@ var SchemaUtils = class {
|
|
|
1585
1597
|
if (enumFieldType === this.config.Ts.Keyword.Undefined) return;
|
|
1586
1598
|
return internalCase(enumFieldType);
|
|
1587
1599
|
}
|
|
1588
|
-
if (lodash.default.keys(schema.properties).length) return SCHEMA_TYPES.OBJECT;
|
|
1589
|
-
if (schema.items) return SCHEMA_TYPES.ARRAY;
|
|
1600
|
+
if (lodash.default.keys(schema.properties).length) return SCHEMA_TYPES$1.OBJECT;
|
|
1601
|
+
if (schema.items) return SCHEMA_TYPES$1.ARRAY;
|
|
1590
1602
|
return null;
|
|
1591
1603
|
};
|
|
1592
1604
|
checkAndAddRequiredKeys = (schema, resultType) => {
|
|
@@ -1630,26 +1642,26 @@ var SchemaUtils = class {
|
|
|
1630
1642
|
return this.config.componentTypeNameResolver.resolve([...(prefixes || []).map((prefix) => pascalCase(`${prefix} ${typeName}`)), ...(suffixes || []).map((suffix) => pascalCase(`${typeName} ${suffix}`))], shouldReserve);
|
|
1631
1643
|
};
|
|
1632
1644
|
getComplexType = (schema) => {
|
|
1633
|
-
if (schema.oneOf) return SCHEMA_TYPES.COMPLEX_ONE_OF;
|
|
1634
|
-
if (schema.allOf) return SCHEMA_TYPES.COMPLEX_ALL_OF;
|
|
1635
|
-
if (schema.anyOf) return SCHEMA_TYPES.COMPLEX_ANY_OF;
|
|
1636
|
-
if (schema.not) return SCHEMA_TYPES.COMPLEX_NOT;
|
|
1637
|
-
return SCHEMA_TYPES.COMPLEX_UNKNOWN;
|
|
1645
|
+
if (schema.oneOf) return SCHEMA_TYPES$1.COMPLEX_ONE_OF;
|
|
1646
|
+
if (schema.allOf) return SCHEMA_TYPES$1.COMPLEX_ALL_OF;
|
|
1647
|
+
if (schema.anyOf) return SCHEMA_TYPES$1.COMPLEX_ANY_OF;
|
|
1648
|
+
if (schema.not) return SCHEMA_TYPES$1.COMPLEX_NOT;
|
|
1649
|
+
return SCHEMA_TYPES$1.COMPLEX_UNKNOWN;
|
|
1638
1650
|
};
|
|
1639
1651
|
getInternalSchemaType = (schema) => {
|
|
1640
|
-
if (!lodash.default.isEmpty(schema.enum) || !lodash.default.isEmpty(this.getEnumNames(schema))) return SCHEMA_TYPES.ENUM;
|
|
1641
|
-
if (schema.discriminator) return SCHEMA_TYPES.DISCRIMINATOR;
|
|
1642
|
-
if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) return SCHEMA_TYPES.COMPLEX;
|
|
1643
|
-
if (!lodash.default.isEmpty(schema.properties)) return SCHEMA_TYPES.OBJECT;
|
|
1644
|
-
if (schema.type === SCHEMA_TYPES.ARRAY) return SCHEMA_TYPES.ARRAY;
|
|
1645
|
-
return SCHEMA_TYPES.PRIMITIVE;
|
|
1652
|
+
if (!lodash.default.isEmpty(schema.enum) || !lodash.default.isEmpty(this.getEnumNames(schema))) return SCHEMA_TYPES$1.ENUM;
|
|
1653
|
+
if (schema.discriminator) return SCHEMA_TYPES$1.DISCRIMINATOR;
|
|
1654
|
+
if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) return SCHEMA_TYPES$1.COMPLEX;
|
|
1655
|
+
if (!lodash.default.isEmpty(schema.properties)) return SCHEMA_TYPES$1.OBJECT;
|
|
1656
|
+
if (schema.type === SCHEMA_TYPES$1.ARRAY) return SCHEMA_TYPES$1.ARRAY;
|
|
1657
|
+
return SCHEMA_TYPES$1.PRIMITIVE;
|
|
1646
1658
|
};
|
|
1647
1659
|
getSchemaType = (schema) => {
|
|
1648
1660
|
if (!schema) return this.config.Ts.Keyword.Any;
|
|
1649
1661
|
const refTypeInfo = this.getSchemaRefType(schema);
|
|
1650
1662
|
if (refTypeInfo) return this.checkAndAddRequiredKeys(schema, this.safeAddNullToType(schema, this.typeNameFormatter.format(refTypeInfo.typeName)));
|
|
1651
1663
|
let resultType;
|
|
1652
|
-
if (this.isConstantSchema(schema)) resultType = this.formatJsValue(schema.const);
|
|
1664
|
+
if (this.isConstantSchema(schema) && !schema.enum) resultType = this.formatJsValue(schema.const);
|
|
1653
1665
|
else {
|
|
1654
1666
|
const primitiveType = this.getSchemaPrimitiveType(schema);
|
|
1655
1667
|
if (primitiveType == null) return this.config.Ts.Keyword.Any;
|
|
@@ -1673,10 +1685,9 @@ var SchemaUtils = class {
|
|
|
1673
1685
|
case "string": return this.config.Ts.StringValue(value);
|
|
1674
1686
|
case "boolean": return this.config.Ts.BooleanValue(value);
|
|
1675
1687
|
case "number": return this.config.Ts.NumberValue(value);
|
|
1676
|
-
default:
|
|
1688
|
+
default:
|
|
1677
1689
|
if (value === null) return this.config.Ts.NullValue(value);
|
|
1678
1690
|
return this.config.Ts.Keyword.Any;
|
|
1679
|
-
}
|
|
1680
1691
|
}
|
|
1681
1692
|
};
|
|
1682
1693
|
};
|
|
@@ -2075,7 +2086,7 @@ var SchemaRoutes = class {
|
|
|
2075
2086
|
};
|
|
2076
2087
|
};
|
|
2077
2088
|
createRequestParamsSchema = ({ queryParams, queryObjectSchema, pathArgsSchemas, extractRequestParams, routeName }) => {
|
|
2078
|
-
if (!queryParams || !queryParams.length) return null;
|
|
2089
|
+
if ((!queryParams || !queryParams.length) && (!pathArgsSchemas || !pathArgsSchemas.length)) return null;
|
|
2079
2090
|
const pathParams = pathArgsSchemas.reduce((acc, pathArgSchema) => {
|
|
2080
2091
|
if (pathArgSchema.name) acc[pathArgSchema.name] = {
|
|
2081
2092
|
...pathArgSchema,
|
|
@@ -2368,8 +2379,8 @@ var SchemaRoutes = class {
|
|
|
2368
2379
|
var SchemaWalker = class {
|
|
2369
2380
|
config;
|
|
2370
2381
|
swaggerSchemaResolver;
|
|
2371
|
-
schemas = new Map();
|
|
2372
|
-
caches = new Map();
|
|
2382
|
+
schemas = /* @__PURE__ */ new Map();
|
|
2383
|
+
caches = /* @__PURE__ */ new Map();
|
|
2373
2384
|
constructor(config, swaggerSchemaResolver) {
|
|
2374
2385
|
this.config = config;
|
|
2375
2386
|
this.swaggerSchemaResolver = swaggerSchemaResolver;
|
|
@@ -2505,6 +2516,7 @@ var SwaggerSchemaResolver = class {
|
|
|
2505
2516
|
|
|
2506
2517
|
//#endregion
|
|
2507
2518
|
//#region src/templates-worker.ts
|
|
2519
|
+
const require$1 = node_module.createRequire(require("url").pathToFileURL(__filename).href);
|
|
2508
2520
|
var TemplatesWorker = class {
|
|
2509
2521
|
config;
|
|
2510
2522
|
fileSystem;
|
|
@@ -2537,10 +2549,10 @@ var TemplatesWorker = class {
|
|
|
2537
2549
|
const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
|
|
2538
2550
|
return pathVariants.find((variant) => !!this.fileSystem.pathIsExist(variant));
|
|
2539
2551
|
};
|
|
2540
|
-
requireFnFromTemplate =
|
|
2552
|
+
requireFnFromTemplate = (packageOrPath) => {
|
|
2541
2553
|
const isPath = packageOrPath.startsWith("./") || packageOrPath.startsWith("../");
|
|
2542
|
-
if (isPath) return
|
|
2543
|
-
return
|
|
2554
|
+
if (isPath) return require$1(node_path.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
|
|
2555
|
+
return require$1(packageOrPath);
|
|
2544
2556
|
};
|
|
2545
2557
|
getTemplate = (name$1, fileName, path$1) => {
|
|
2546
2558
|
const { templatePaths } = this.config;
|
|
@@ -2658,7 +2670,7 @@ var JavascriptTranslator = class extends Translator {
|
|
|
2658
2670
|
//#endregion
|
|
2659
2671
|
//#region src/type-name-formatter.ts
|
|
2660
2672
|
var TypeNameFormatter = class {
|
|
2661
|
-
formattedModelNamesMap = new Map();
|
|
2673
|
+
formattedModelNamesMap = /* @__PURE__ */ new Map();
|
|
2662
2674
|
config;
|
|
2663
2675
|
constructor(config) {
|
|
2664
2676
|
this.config = config;
|
|
@@ -3047,6 +3059,32 @@ var CodeGenProcess = class {
|
|
|
3047
3059
|
};
|
|
3048
3060
|
};
|
|
3049
3061
|
|
|
3062
|
+
//#endregion
|
|
3063
|
+
//#region types/index.ts
|
|
3064
|
+
let RequestContentKind = /* @__PURE__ */ function(RequestContentKind$1) {
|
|
3065
|
+
RequestContentKind$1["JSON"] = "JSON";
|
|
3066
|
+
RequestContentKind$1["URL_ENCODED"] = "URL_ENCODED";
|
|
3067
|
+
RequestContentKind$1["FORM_DATA"] = "FORM_DATA";
|
|
3068
|
+
RequestContentKind$1["IMAGE"] = "IMAGE";
|
|
3069
|
+
RequestContentKind$1["OTHER"] = "OTHER";
|
|
3070
|
+
RequestContentKind$1["TEXT"] = "TEXT";
|
|
3071
|
+
return RequestContentKind$1;
|
|
3072
|
+
}({});
|
|
3073
|
+
let SCHEMA_TYPES = /* @__PURE__ */ function(SCHEMA_TYPES$2) {
|
|
3074
|
+
SCHEMA_TYPES$2["ARRAY"] = "array";
|
|
3075
|
+
SCHEMA_TYPES$2["OBJECT"] = "object";
|
|
3076
|
+
SCHEMA_TYPES$2["ENUM"] = "enum";
|
|
3077
|
+
SCHEMA_TYPES$2["REF"] = "$ref";
|
|
3078
|
+
SCHEMA_TYPES$2["PRIMITIVE"] = "primitive";
|
|
3079
|
+
SCHEMA_TYPES$2["COMPLEX"] = "complex";
|
|
3080
|
+
SCHEMA_TYPES$2["COMPLEX_ONE_OF"] = "oneOf";
|
|
3081
|
+
SCHEMA_TYPES$2["COMPLEX_ANY_OF"] = "anyOf";
|
|
3082
|
+
SCHEMA_TYPES$2["COMPLEX_ALL_OF"] = "allOf";
|
|
3083
|
+
SCHEMA_TYPES$2["COMPLEX_NOT"] = "not";
|
|
3084
|
+
SCHEMA_TYPES$2["COMPLEX_UNKNOWN"] = "__unknown";
|
|
3085
|
+
return SCHEMA_TYPES$2;
|
|
3086
|
+
}({});
|
|
3087
|
+
|
|
3050
3088
|
//#endregion
|
|
3051
3089
|
//#region src/commands/generate-templates/configuration.ts
|
|
3052
3090
|
var TemplatesGenConfig = class {
|
|
@@ -3200,6 +3238,18 @@ Object.defineProperty(exports, 'HTTP_CLIENT', {
|
|
|
3200
3238
|
return HTTP_CLIENT;
|
|
3201
3239
|
}
|
|
3202
3240
|
});
|
|
3241
|
+
Object.defineProperty(exports, 'RequestContentKind', {
|
|
3242
|
+
enumerable: true,
|
|
3243
|
+
get: function () {
|
|
3244
|
+
return RequestContentKind;
|
|
3245
|
+
}
|
|
3246
|
+
});
|
|
3247
|
+
Object.defineProperty(exports, 'SCHEMA_TYPES', {
|
|
3248
|
+
enumerable: true,
|
|
3249
|
+
get: function () {
|
|
3250
|
+
return SCHEMA_TYPES;
|
|
3251
|
+
}
|
|
3252
|
+
});
|
|
3203
3253
|
Object.defineProperty(exports, 'TemplatesGenConfig', {
|
|
3204
3254
|
enumerable: true,
|
|
3205
3255
|
get: function () {
|
|
@@ -3236,4 +3286,4 @@ Object.defineProperty(exports, 'package_default', {
|
|
|
3236
3286
|
return package_default;
|
|
3237
3287
|
}
|
|
3238
3288
|
});
|
|
3239
|
-
//# sourceMappingURL=src-
|
|
3289
|
+
//# sourceMappingURL=src-C5bMYV9w.cjs.map
|