swagger-typescript-api 13.2.16 → 13.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/cli.cjs +14 -15
- package/dist/cli.cjs.map +1 -1
- package/dist/{cli.js → cli.mjs} +3 -2
- package/dist/cli.mjs.map +1 -0
- package/dist/{src-DWf638kx.cjs → generate-templates-C4JBmSNw.cjs} +377 -359
- package/dist/generate-templates-C4JBmSNw.cjs.map +1 -0
- package/dist/{src-D-LZ3PGk.js → generate-templates-DGQlyLhe.mjs} +349 -337
- package/dist/generate-templates-DGQlyLhe.mjs.map +1 -0
- package/dist/index.cjs +17 -6
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +179 -289
- package/dist/index.d.cts.map +1 -1
- package/dist/{index.d.ts → index.d.mts} +179 -290
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +24 -28
- package/templates/base/data-contract-jsdoc.ejs +16 -16
- package/templates/base/object-field-jsdoc.ejs +8 -8
- package/templates/base/route-docs.ejs +7 -7
- package/templates/default/api.ejs +11 -11
- package/templates/default/procedure-call.ejs +1 -1
- package/templates/modular/procedure-call.ejs +1 -1
- package/CHANGELOG.md +0 -1770
- package/dist/chunk-Bp6m_JJh.js +0 -13
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/src-D-LZ3PGk.js.map +0 -1
- package/dist/src-DWf638kx.cjs.map +0 -1
- /package/dist/{cli.d.ts → cli.d.mts} +0 -0
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as __exportAll } from "./chunk-DQk6qfdC.mjs";
|
|
2
2
|
import * as module from "node:module";
|
|
3
3
|
import { consola } from "consola";
|
|
4
|
-
import
|
|
4
|
+
import * as esToolkit from "es-toolkit";
|
|
5
|
+
import { compact, flattenDeep, isEqual, merge, omit, uniq } from "es-toolkit";
|
|
6
|
+
import * as esToolkitCompat from "es-toolkit/compat";
|
|
7
|
+
import { camelCase, get, startCase, upperFirst } from "es-toolkit/compat";
|
|
5
8
|
import * as typescript from "typescript";
|
|
6
9
|
import * as path$1 from "node:path";
|
|
7
10
|
import path from "node:path";
|
|
8
11
|
import { Biome, Distribution } from "@biomejs/js-api";
|
|
9
12
|
import * as nanoid from "nanoid";
|
|
13
|
+
import * as crypto from "node:crypto";
|
|
10
14
|
import * as swagger2openapi from "swagger2openapi";
|
|
11
15
|
import * as YAML from "yaml";
|
|
12
16
|
import * as url$1 from "node:url";
|
|
@@ -27,7 +31,7 @@ var CodeFormatter = class {
|
|
|
27
31
|
type: "file",
|
|
28
32
|
fileName: tempFileName
|
|
29
33
|
}, { newLineCharacter: typescript.sys.newLine }, void 0)[0];
|
|
30
|
-
if (fileTextChanges?.textChanges.length) return fileTextChanges.textChanges.reduceRight((content
|
|
34
|
+
if (fileTextChanges?.textChanges.length) return fileTextChanges.textChanges.reduceRight((content, { span, newText }) => `${content.slice(0, span.start)}${newText}${content.slice(span.start + span.length)}`, content);
|
|
31
35
|
return content;
|
|
32
36
|
};
|
|
33
37
|
format = async (content) => {
|
|
@@ -83,8 +87,8 @@ var TsLanguageServiceHost = class {
|
|
|
83
87
|
if (fileName === this.fileName) return this.content;
|
|
84
88
|
return typescript.sys.readFile(fileName, encoding);
|
|
85
89
|
}
|
|
86
|
-
fileExists(path
|
|
87
|
-
return typescript.sys.fileExists(path
|
|
90
|
+
fileExists(path) {
|
|
91
|
+
return typescript.sys.fileExists(path);
|
|
88
92
|
}
|
|
89
93
|
};
|
|
90
94
|
|
|
@@ -100,14 +104,14 @@ var NameResolver = class {
|
|
|
100
104
|
this.reserve(reservedNames);
|
|
101
105
|
}
|
|
102
106
|
reserve(names) {
|
|
103
|
-
const fixedNames =
|
|
104
|
-
for (const name
|
|
107
|
+
const fixedNames = uniq(compact(names));
|
|
108
|
+
for (const name of fixedNames) if (this.reservedNames.indexOf(name) === -1) this.reservedNames.push(name);
|
|
105
109
|
}
|
|
106
110
|
unreserve(names) {
|
|
107
|
-
this.reservedNames = this.reservedNames.filter((reservedName) => !names.some((name
|
|
111
|
+
this.reservedNames = this.reservedNames.filter((reservedName) => !names.some((name) => name === reservedName));
|
|
108
112
|
}
|
|
109
|
-
isReserved(name
|
|
110
|
-
return this.reservedNames.some((reservedName) => reservedName === name
|
|
113
|
+
isReserved(name) {
|
|
114
|
+
return this.reservedNames.some((reservedName) => reservedName === name);
|
|
111
115
|
}
|
|
112
116
|
resolve(variants, resolver, extras, shouldReserve = true) {
|
|
113
117
|
if (typeof resolver === "function") {
|
|
@@ -125,7 +129,7 @@ var NameResolver = class {
|
|
|
125
129
|
}
|
|
126
130
|
if (Array.isArray(variants)) {
|
|
127
131
|
let usageName = null;
|
|
128
|
-
const uniqVariants =
|
|
132
|
+
const uniqVariants = uniq(compact(variants));
|
|
129
133
|
for (const variant of uniqVariants) if (!usageName && (!shouldReserve || !this.isReserved(variant))) usageName = variant;
|
|
130
134
|
if (usageName) {
|
|
131
135
|
shouldReserve && this.reserve([usageName]);
|
|
@@ -141,12 +145,9 @@ var NameResolver = class {
|
|
|
141
145
|
|
|
142
146
|
//#endregion
|
|
143
147
|
//#region src/util/random.ts
|
|
144
|
-
const getRandomFloat = (min = 0, max = 1) => {
|
|
145
|
-
return Math.random() * (max - min) + min;
|
|
146
|
-
};
|
|
147
148
|
const getRandomInt = (min = 0, max = 1) => {
|
|
148
149
|
if (min === max) return min;
|
|
149
|
-
return Math.round(
|
|
150
|
+
return Math.round(Math.random() * (max - min) + min);
|
|
150
151
|
};
|
|
151
152
|
|
|
152
153
|
//#endregion
|
|
@@ -176,12 +177,12 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
176
177
|
//#endregion
|
|
177
178
|
//#region package.json
|
|
178
179
|
var name = "swagger-typescript-api";
|
|
179
|
-
var version = "13.2.
|
|
180
|
+
var version = "13.2.18";
|
|
180
181
|
var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
|
|
181
182
|
|
|
182
183
|
//#endregion
|
|
183
184
|
//#region src/constants.ts
|
|
184
|
-
var constants_exports = /* @__PURE__ */
|
|
185
|
+
var constants_exports = /* @__PURE__ */ __exportAll({
|
|
185
186
|
DEFAULT_BODY_ARG_NAME: () => DEFAULT_BODY_ARG_NAME,
|
|
186
187
|
FILE_PREFIX: () => FILE_PREFIX,
|
|
187
188
|
HTTP_CLIENT: () => HTTP_CLIENT,
|
|
@@ -250,8 +251,9 @@ const SCHEMA_TYPES$1 = {
|
|
|
250
251
|
const objectAssign = (target, updater) => {
|
|
251
252
|
if (!updater) return;
|
|
252
253
|
const update = typeof updater === "function" ? updater(target) : updater;
|
|
253
|
-
|
|
254
|
-
Object.
|
|
254
|
+
if (!update) return;
|
|
255
|
+
const undefinedKeys = Object.entries(update).filter(([, value]) => value === void 0).map(([key]) => key);
|
|
256
|
+
merge(target, update);
|
|
255
257
|
for (const key of undefinedKeys) target[key] = void 0;
|
|
256
258
|
};
|
|
257
259
|
|
|
@@ -455,11 +457,11 @@ var CodeGenConfig = class {
|
|
|
455
457
|
BooleanValue: (content) => `${content}`,
|
|
456
458
|
NumberValue: (content) => `${content}`,
|
|
457
459
|
NullValue: () => "null",
|
|
458
|
-
UnionType: (contents) =>
|
|
460
|
+
UnionType: (contents) => uniq(contents).join(` ${this.Ts.Keyword.Union} `),
|
|
459
461
|
ExpressionGroup: (content) => content ? `(${content})` : "",
|
|
460
|
-
IntersectionType: (contents) =>
|
|
462
|
+
IntersectionType: (contents) => uniq(contents).join(` ${this.Ts.Keyword.Intersection} `),
|
|
461
463
|
RecordType: (key, value) => this.Ts.TypeWithGeneric(this.Ts.Keyword.Record, [key, value]),
|
|
462
|
-
TypeField: ({ readonly, key, optional, value }) =>
|
|
464
|
+
TypeField: ({ readonly, key, optional, value }) => compact([
|
|
463
465
|
readonly && "readonly ",
|
|
464
466
|
key,
|
|
465
467
|
optional && "?",
|
|
@@ -469,12 +471,12 @@ var CodeGenConfig = class {
|
|
|
469
471
|
InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`,
|
|
470
472
|
EnumUsageKey: (enumStruct, key) => `${enumStruct}.${key}`,
|
|
471
473
|
EnumField: (key, value) => `${key} = ${value}`,
|
|
472
|
-
EnumFieldDescription: (description
|
|
473
|
-
if (description
|
|
474
|
+
EnumFieldDescription: (description) => {
|
|
475
|
+
if (description) return ` /** ${description} */`;
|
|
474
476
|
else return "";
|
|
475
477
|
},
|
|
476
|
-
EnumFieldsWrapper: (contents) =>
|
|
477
|
-
return [this.Ts.EnumFieldDescription(description
|
|
478
|
+
EnumFieldsWrapper: (contents) => contents.map(({ key, value, description }) => {
|
|
479
|
+
return compact([this.Ts.EnumFieldDescription(description), ` ${this.Ts.EnumField(key, value)}`]).join("\n");
|
|
478
480
|
}).join(",\n"),
|
|
479
481
|
ObjectWrapper: (content) => `{\n${content}\n}`,
|
|
480
482
|
MultilineComment: (contents, formatFn) => [...contents.length === 1 ? [`/** ${contents[0]} */`] : [
|
|
@@ -564,13 +566,13 @@ var CodeGenConfig = class {
|
|
|
564
566
|
}
|
|
565
567
|
];
|
|
566
568
|
templateExtensions = [".eta", ".ejs"];
|
|
567
|
-
constructor({ codeGenConstructs, primitiveTypeConstructs, constants, templateInfos, hooks
|
|
569
|
+
constructor({ codeGenConstructs, primitiveTypeConstructs, constants, templateInfos, hooks, ...otherConfig }) {
|
|
568
570
|
objectAssign(this.Ts, codeGenConstructs);
|
|
569
571
|
objectAssign(this.primitiveTypes, primitiveTypeConstructs);
|
|
570
572
|
this.defaultResponseType = this.Ts.Keyword.Void;
|
|
571
573
|
this.update({
|
|
572
574
|
...otherConfig,
|
|
573
|
-
hooks:
|
|
575
|
+
hooks: merge(this.hooks, hooks || {}),
|
|
574
576
|
constants: {
|
|
575
577
|
...constants_exports,
|
|
576
578
|
...constants
|
|
@@ -666,10 +668,14 @@ var SchemaFormatters = class {
|
|
|
666
668
|
$content: parsedSchema.content,
|
|
667
669
|
content: this.config.Ts.UnionType(parsedSchema.content.map(({ value }) => value))
|
|
668
670
|
};
|
|
671
|
+
const escapedContent = parsedSchema.content.map((item) => ({
|
|
672
|
+
...item,
|
|
673
|
+
description: item.description ? this.escapeJSDocContent(item.description) : ""
|
|
674
|
+
}));
|
|
669
675
|
return {
|
|
670
676
|
...parsedSchema,
|
|
671
677
|
$content: parsedSchema.content,
|
|
672
|
-
content: this.config.Ts.EnumFieldsWrapper(
|
|
678
|
+
content: this.config.Ts.EnumFieldsWrapper(escapedContent)
|
|
673
679
|
};
|
|
674
680
|
},
|
|
675
681
|
[SCHEMA_TYPES$1.OBJECT]: (parsedSchema) => {
|
|
@@ -691,7 +697,7 @@ var SchemaFormatters = class {
|
|
|
691
697
|
[SCHEMA_TYPES$1.ENUM]: (parsedSchema) => {
|
|
692
698
|
return {
|
|
693
699
|
...parsedSchema,
|
|
694
|
-
content: parsedSchema.$ref ? parsedSchema.typeName : this.config.Ts.UnionType(
|
|
700
|
+
content: parsedSchema.$ref ? parsedSchema.typeName : this.config.Ts.UnionType(compact([...parsedSchema.content.map(({ value }) => `${value}`), parsedSchema.nullable && this.config.Ts.Keyword.Null])) || this.config.Ts.Keyword.Any
|
|
695
701
|
};
|
|
696
702
|
},
|
|
697
703
|
[SCHEMA_TYPES$1.OBJECT]: (parsedSchema) => {
|
|
@@ -708,14 +714,19 @@ var SchemaFormatters = class {
|
|
|
708
714
|
}
|
|
709
715
|
};
|
|
710
716
|
formatSchema = (parsedSchema, formatType = "base") => {
|
|
711
|
-
const schemaType =
|
|
712
|
-
return
|
|
717
|
+
const schemaType = get(parsedSchema, ["schemaType"]) || get(parsedSchema, ["$parsed", "schemaType"]);
|
|
718
|
+
return get(this, [formatType, schemaType])?.(parsedSchema) || parsedSchema;
|
|
719
|
+
};
|
|
720
|
+
escapeJSDocContent = (content) => {
|
|
721
|
+
if (content === void 0) return "";
|
|
722
|
+
return (typeof content === "string" ? content : String(content)).replace(/\*\//g, "*\\/");
|
|
713
723
|
};
|
|
714
|
-
formatDescription = (description
|
|
715
|
-
if (!description
|
|
716
|
-
|
|
717
|
-
if (
|
|
718
|
-
return
|
|
724
|
+
formatDescription = (description, inline) => {
|
|
725
|
+
if (!description) return "";
|
|
726
|
+
const escapedDescription = this.escapeJSDocContent(description);
|
|
727
|
+
if (!escapedDescription.includes("\n")) return escapedDescription;
|
|
728
|
+
if (inline) return compact(escapedDescription.split(/\n/g).map((part) => part.trim())).join(" ");
|
|
729
|
+
return escapedDescription.replace(/\n$/g, "");
|
|
719
730
|
};
|
|
720
731
|
formatObjectContent = (content) => {
|
|
721
732
|
const fields = [];
|
|
@@ -776,7 +787,7 @@ var MonoSchemaParser = class {
|
|
|
776
787
|
var ArraySchemaParser = class extends MonoSchemaParser {
|
|
777
788
|
parse() {
|
|
778
789
|
let contentType;
|
|
779
|
-
const { type, description
|
|
790
|
+
const { type, description, items } = this.schema || {};
|
|
780
791
|
if (Array.isArray(items) && type === SCHEMA_TYPES$1.ARRAY) {
|
|
781
792
|
const tupleContent = [];
|
|
782
793
|
for (const item of items) tupleContent.push(this.schemaParserFabric.createSchemaParser({
|
|
@@ -799,7 +810,7 @@ var ArraySchemaParser = class extends MonoSchemaParser {
|
|
|
799
810
|
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
800
811
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
801
812
|
name: this.typeName,
|
|
802
|
-
description: this.schemaFormatters.formatDescription(description
|
|
813
|
+
description: this.schemaFormatters.formatDescription(description),
|
|
803
814
|
content: this.schemaUtils.safeAddNullToType(this.schema, contentType)
|
|
804
815
|
};
|
|
805
816
|
}
|
|
@@ -810,7 +821,7 @@ var ArraySchemaParser = class extends MonoSchemaParser {
|
|
|
810
821
|
var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
811
822
|
parse() {
|
|
812
823
|
const complexType = this.schemaUtils.getComplexType(this.schema);
|
|
813
|
-
const simpleSchema =
|
|
824
|
+
const simpleSchema = omit(this.schema, Object.keys(this.schemaParser._complexSchemaParsers));
|
|
814
825
|
const complexSchemaContent = this.schemaParser._complexSchemaParsers[complexType](this.schema);
|
|
815
826
|
return {
|
|
816
827
|
...typeof this.schema === "object" ? this.schema : {},
|
|
@@ -820,8 +831,8 @@ var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
|
820
831
|
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
821
832
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
822
833
|
name: this.typeName,
|
|
823
|
-
description: this.schemaFormatters.formatDescription(this.schema.description ||
|
|
824
|
-
content: this.config.Ts.IntersectionType(
|
|
834
|
+
description: this.schemaFormatters.formatDescription(this.schema.description || compact((this.schema[complexType] || []).map((item) => item?.description))[0] || ""),
|
|
835
|
+
content: this.config.Ts.IntersectionType(compact([this.config.Ts.ExpressionGroup(complexSchemaContent), this.schemaUtils.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES$1.OBJECT && this.config.Ts.ExpressionGroup(this.schemaParserFabric.createSchemaParser({
|
|
825
836
|
schema: simpleSchema,
|
|
826
837
|
schemaPath: this.schemaPath
|
|
827
838
|
}).getInlineParseContent())])) || this.config.Ts.Keyword.Any
|
|
@@ -834,7 +845,7 @@ var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
|
834
845
|
var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
835
846
|
parse() {
|
|
836
847
|
const ts = this.config.Ts;
|
|
837
|
-
const { discriminator
|
|
848
|
+
const { discriminator, ...noDiscriminatorSchema } = this.schema;
|
|
838
849
|
if (!discriminator.mapping) return this.schemaParserFabric.createSchemaParser({
|
|
839
850
|
schema: noDiscriminatorSchema,
|
|
840
851
|
typeName: this.typeName,
|
|
@@ -846,7 +857,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
846
857
|
skipMappingType,
|
|
847
858
|
abstractSchemaStruct
|
|
848
859
|
});
|
|
849
|
-
const schemaContent = ts.IntersectionType([abstractSchemaStruct?.content, discriminatorSchemaStruct?.content]
|
|
860
|
+
const schemaContent = ts.IntersectionType(compact([abstractSchemaStruct?.content, discriminatorSchemaStruct?.content]));
|
|
850
861
|
return {
|
|
851
862
|
...typeof this.schema === "object" ? this.schema : {},
|
|
852
863
|
$schemaPath: this.schemaPath.slice(),
|
|
@@ -867,7 +878,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
867
878
|
this.typeName
|
|
868
879
|
]);
|
|
869
880
|
const { discriminator } = this.schema;
|
|
870
|
-
const mappingEntries =
|
|
881
|
+
const mappingEntries = Object.entries(discriminator.mapping || {});
|
|
871
882
|
const ableToCreateMappingType = !skipMappingType && !!(abstractSchemaStruct?.typeName && mappingEntries.length);
|
|
872
883
|
const mappingContents = [];
|
|
873
884
|
let mappingTypeName;
|
|
@@ -927,22 +938,24 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
927
938
|
};
|
|
928
939
|
createMappingPropertySchemaEnumKeys = ({ abstractSchemaStruct, discPropertyName }) => {
|
|
929
940
|
const ts = this.config.Ts;
|
|
930
|
-
|
|
931
|
-
let mappingPropertySchema =
|
|
941
|
+
const mappingPropertySchemaEnumKeysMap = {};
|
|
942
|
+
let mappingPropertySchema = get(abstractSchemaStruct?.component?.rawTypeData, ["properties", discPropertyName]);
|
|
932
943
|
if (this.schemaUtils.isRefSchema(mappingPropertySchema)) mappingPropertySchema = this.schemaUtils.getSchemaRefType(mappingPropertySchema);
|
|
933
944
|
const parsedEnum = mappingPropertySchema?.rawTypeData?.$parsed;
|
|
934
|
-
if (parsedEnum?.type === SCHEMA_TYPES$1.ENUM)
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
const
|
|
938
|
-
if (
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
945
|
+
if (parsedEnum?.type === SCHEMA_TYPES$1.ENUM) {
|
|
946
|
+
const enumEntries = (parsedEnum.enum || []).map((key, index) => [key, index]);
|
|
947
|
+
for (const [key, index] of enumEntries) {
|
|
948
|
+
const enumContent = parsedEnum.content?.[index];
|
|
949
|
+
if (this.config.generateUnionEnums) {
|
|
950
|
+
const literalValue = enumContent?.value ?? (key !== void 0 ? ts.StringValue(key) : void 0);
|
|
951
|
+
if (literalValue !== void 0) mappingPropertySchemaEnumKeysMap[key] = literalValue;
|
|
952
|
+
} else if (parsedEnum.typeName && enumContent?.key) mappingPropertySchemaEnumKeysMap[key] = ts.EnumUsageKey(parsedEnum.typeName, enumContent.key);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
942
955
|
return mappingPropertySchemaEnumKeysMap;
|
|
943
956
|
};
|
|
944
957
|
mutateMappingDependentSchema = ({ discPropertyName, abstractSchemaStruct, mappingSchema, refPath, mappingPropertySchemaEnumKeysMap }) => {
|
|
945
|
-
const complexSchemaKeys =
|
|
958
|
+
const complexSchemaKeys = Object.keys(this.schemaParser._complexSchemaParsers);
|
|
946
959
|
if (mappingSchema.$ref && abstractSchemaStruct?.component?.$ref) {
|
|
947
960
|
const mappingRefSchema = this.schemaUtils.getSchemaRefType(mappingSchema)?.rawTypeData;
|
|
948
961
|
if (mappingRefSchema) {
|
|
@@ -961,11 +974,11 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
961
974
|
}
|
|
962
975
|
};
|
|
963
976
|
createAbstractSchemaStruct = () => {
|
|
964
|
-
const { discriminator
|
|
965
|
-
const complexSchemaKeys =
|
|
966
|
-
const schema =
|
|
977
|
+
const { discriminator, ...noDiscriminatorSchema } = this.schema;
|
|
978
|
+
const complexSchemaKeys = Object.keys(this.schemaParser._complexSchemaParsers);
|
|
979
|
+
const schema = omit(structuredClone(noDiscriminatorSchema), complexSchemaKeys);
|
|
967
980
|
const schemaIsAny = this.schemaParserFabric.getInlineParseContent(structuredClone(schema)) === this.config.Ts.Keyword.Any;
|
|
968
|
-
if (!
|
|
981
|
+
if (!Object.keys(schema).length || schemaIsAny) return null;
|
|
969
982
|
const typeName = this.schemaUtils.resolveTypeName(this.typeName, {
|
|
970
983
|
prefixes: this.config.extractingOptions.discriminatorAbstractPrefix,
|
|
971
984
|
resolver: this.config.extractingOptions.discriminatorAbstractResolver
|
|
@@ -1034,9 +1047,9 @@ var EnumSchemaParser = class extends MonoSchemaParser {
|
|
|
1034
1047
|
const refType = this.schemaUtils.getSchemaRefType(this.schema);
|
|
1035
1048
|
const $ref = refType?.$ref || null;
|
|
1036
1049
|
if (Array.isArray(this.schema.enum)) this.schema.enum = this.schema.enum.filter((key) => key != null);
|
|
1037
|
-
if (Array.isArray(this.schema.enum) && Array.isArray(this.schema.enum[0])) return this.schemaParserFabric.parseSchema({ oneOf: this.schema.enum.map((enumNames
|
|
1050
|
+
if (Array.isArray(this.schema.enum) && Array.isArray(this.schema.enum[0])) return this.schemaParserFabric.parseSchema({ oneOf: this.schema.enum.map((enumNames) => ({
|
|
1038
1051
|
type: "array",
|
|
1039
|
-
items: enumNames
|
|
1052
|
+
items: enumNames.map((enumName) => ({
|
|
1040
1053
|
type: "string",
|
|
1041
1054
|
enum: [enumName]
|
|
1042
1055
|
}))
|
|
@@ -1061,8 +1074,8 @@ var EnumSchemaParser = class extends MonoSchemaParser {
|
|
|
1061
1074
|
default: return this.config.Ts.StringValue(value);
|
|
1062
1075
|
}
|
|
1063
1076
|
};
|
|
1064
|
-
if (Array.isArray(enumNames) &&
|
|
1065
|
-
const enumValue =
|
|
1077
|
+
if (Array.isArray(enumNames) && enumNames.length > 0) content = enumNames.map((enumName, index) => {
|
|
1078
|
+
const enumValue = get(this.schema.enum, index);
|
|
1066
1079
|
const formattedKey = this.formatEnumKey({
|
|
1067
1080
|
key: enumName,
|
|
1068
1081
|
value: enumValue
|
|
@@ -1130,21 +1143,24 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
|
|
|
1130
1143
|
}
|
|
1131
1144
|
getObjectSchemaContent = (schema) => {
|
|
1132
1145
|
const { properties, additionalProperties } = schema || {};
|
|
1133
|
-
const propertiesContent =
|
|
1134
|
-
|
|
1135
|
-
const
|
|
1146
|
+
const propertiesContent = [];
|
|
1147
|
+
for (const [name, property] of Object.entries(properties || {})) {
|
|
1148
|
+
const required = this.schemaUtils.isPropertyRequired(name, property, schema);
|
|
1149
|
+
const rawTypeData = get(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {});
|
|
1136
1150
|
const nullable = !!(rawTypeData.nullable || property.nullable);
|
|
1137
|
-
const fieldName = this.typeNameFormatter.isValidName(name
|
|
1151
|
+
const fieldName = this.typeNameFormatter.isValidName(name) ? name : this.config.Ts.StringValue(name);
|
|
1138
1152
|
const fieldValue = this.schemaParserFabric.createSchemaParser({
|
|
1139
1153
|
schema: property,
|
|
1140
|
-
schemaPath: [...this.schemaPath, name
|
|
1154
|
+
schemaPath: [...this.schemaPath, name]
|
|
1141
1155
|
}).getInlineParseContent();
|
|
1142
1156
|
const readOnly = property.readOnly;
|
|
1143
|
-
|
|
1157
|
+
const complexType = this.schemaUtils.getComplexType(property);
|
|
1158
|
+
const rawDataComplexType = this.schemaUtils.getComplexType(rawTypeData);
|
|
1159
|
+
propertiesContent.push({
|
|
1144
1160
|
...property,
|
|
1145
1161
|
$$raw: property,
|
|
1146
1162
|
title: property.title,
|
|
1147
|
-
description: property.description ||
|
|
1163
|
+
description: property.description || compact((property[complexType] || []).map((item) => item?.description))[0] || rawTypeData.description || compact((rawTypeData[rawDataComplexType] || []).map((item) => item?.description))[0] || "",
|
|
1148
1164
|
isRequired: required,
|
|
1149
1165
|
isNullable: nullable,
|
|
1150
1166
|
name: fieldName,
|
|
@@ -1155,8 +1171,8 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
|
|
|
1155
1171
|
key: fieldName,
|
|
1156
1172
|
value: fieldValue
|
|
1157
1173
|
})
|
|
1158
|
-
};
|
|
1159
|
-
}
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1160
1176
|
if (additionalProperties) {
|
|
1161
1177
|
const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(schema);
|
|
1162
1178
|
let interfaceKeysContent;
|
|
@@ -1181,7 +1197,7 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
|
|
|
1181
1197
|
var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
1182
1198
|
parse() {
|
|
1183
1199
|
let contentType = null;
|
|
1184
|
-
const { additionalProperties, type, description
|
|
1200
|
+
const { additionalProperties, type, description, items } = this.schema || {};
|
|
1185
1201
|
if (type === this.config.Ts.Keyword.Object && additionalProperties) {
|
|
1186
1202
|
const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(this.schema);
|
|
1187
1203
|
let recordKeysContent;
|
|
@@ -1200,7 +1216,7 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
|
1200
1216
|
}
|
|
1201
1217
|
if (Array.isArray(type) && type.length) contentType = this.schemaParser._complexSchemaParsers.oneOf({
|
|
1202
1218
|
...typeof this.schema === "object" ? this.schema : {},
|
|
1203
|
-
oneOf: type.map((type
|
|
1219
|
+
oneOf: type.map((type) => ({ type }))
|
|
1204
1220
|
});
|
|
1205
1221
|
if (Array.isArray(items) && type === SCHEMA_TYPES$1.ARRAY) contentType = this.config.Ts.Tuple(items.map((item) => this.schemaParserFabric.createSchemaParser({
|
|
1206
1222
|
schema: item,
|
|
@@ -1214,7 +1230,7 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
|
1214
1230
|
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
1215
1231
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
1216
1232
|
name: this.typeName,
|
|
1217
|
-
description: this.schemaFormatters.formatDescription(description
|
|
1233
|
+
description: this.schemaFormatters.formatDescription(description),
|
|
1218
1234
|
content: type === this.config.Ts.Keyword.Null ? type : contentType || this.schemaUtils.getSchemaType(this.schema)
|
|
1219
1235
|
};
|
|
1220
1236
|
}
|
|
@@ -1277,7 +1293,7 @@ var SchemaParser = class {
|
|
|
1277
1293
|
schemaWalker;
|
|
1278
1294
|
typeName;
|
|
1279
1295
|
schema;
|
|
1280
|
-
schemaPath
|
|
1296
|
+
schemaPath;
|
|
1281
1297
|
constructor(schemaParserFabric, { typeName, schema, schemaPath } = {}) {
|
|
1282
1298
|
this.schemaParserFabric = schemaParserFabric;
|
|
1283
1299
|
this.config = schemaParserFabric.config;
|
|
@@ -1349,7 +1365,7 @@ var SchemaParser = class {
|
|
|
1349
1365
|
}
|
|
1350
1366
|
schemaType = this.schemaUtils.getInternalSchemaType(this.schema);
|
|
1351
1367
|
this.schemaPath.push(this.typeName);
|
|
1352
|
-
|
|
1368
|
+
merge(this.schema, this.config.hooks.onPreParseSchema(this.schema, this.typeName, schemaType) || {});
|
|
1353
1369
|
parsedSchema = this._baseSchemaParsers[schemaType](this.schema, this.typeName);
|
|
1354
1370
|
this.schema.$parsed = this.config.hooks.onParseSchema(this.schema, parsedSchema) || parsedSchema;
|
|
1355
1371
|
if (this.config.sortTypes && Array.isArray(this.schema.$parsed?.content)) this.schema.$parsed.content = this.schema.$parsed.content.sort(sortByProperty("name"));
|
|
@@ -1366,28 +1382,23 @@ var SchemaParser = class {
|
|
|
1366
1382
|
return this.schemaFormatters.formatSchema(parsedSchema, "base").content;
|
|
1367
1383
|
};
|
|
1368
1384
|
extractSchemaFromResponseStruct = (responseStruct) => {
|
|
1369
|
-
const { content
|
|
1370
|
-
const firstResponse =
|
|
1371
|
-
const firstSchema =
|
|
1385
|
+
const { content, ...extras } = responseStruct;
|
|
1386
|
+
const firstResponse = Object.values(content || {})[0];
|
|
1387
|
+
const firstSchema = get(firstResponse, "schema");
|
|
1372
1388
|
if (!firstSchema) return;
|
|
1389
|
+
const { schema: _, ...restResponse } = firstResponse || {};
|
|
1373
1390
|
return {
|
|
1374
1391
|
...extras,
|
|
1375
|
-
...
|
|
1392
|
+
...restResponse,
|
|
1376
1393
|
...firstSchema
|
|
1377
1394
|
};
|
|
1378
1395
|
};
|
|
1379
1396
|
};
|
|
1380
1397
|
|
|
1381
|
-
//#endregion
|
|
1382
|
-
//#region src/util/internal-case.ts
|
|
1383
|
-
function internalCase(value) {
|
|
1384
|
-
return lodash.camelCase(lodash.lowerCase(value));
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
1398
|
//#endregion
|
|
1388
1399
|
//#region src/util/pascal-case.ts
|
|
1389
1400
|
function pascalCase(value) {
|
|
1390
|
-
return
|
|
1401
|
+
return upperFirst(camelCase(value));
|
|
1391
1402
|
}
|
|
1392
1403
|
|
|
1393
1404
|
//#endregion
|
|
@@ -1404,7 +1415,7 @@ var SchemaUtils = class {
|
|
|
1404
1415
|
this.schemaWalker = schemaWalker;
|
|
1405
1416
|
}
|
|
1406
1417
|
getRequiredProperties = (schema) => {
|
|
1407
|
-
return
|
|
1418
|
+
return uniq(schema && Array.isArray(schema.required) && schema.required || []);
|
|
1408
1419
|
};
|
|
1409
1420
|
isRefSchema = (schema) => {
|
|
1410
1421
|
return !!schema?.$ref;
|
|
@@ -1423,15 +1434,15 @@ var SchemaUtils = class {
|
|
|
1423
1434
|
if (!this.isRefSchema(schema)) return null;
|
|
1424
1435
|
return this.schemaComponentsMap.get(schema.$ref);
|
|
1425
1436
|
};
|
|
1426
|
-
isPropertyRequired = (name
|
|
1437
|
+
isPropertyRequired = (name, propertySchema, rootSchema) => {
|
|
1427
1438
|
if (propertySchema["x-omitempty"] === false) return true;
|
|
1428
|
-
const isRequired = typeof propertySchema.required === "boolean" ? !!propertySchema.required : Array.isArray(rootSchema.required) ? rootSchema.required.includes(name
|
|
1439
|
+
const isRequired = typeof propertySchema.required === "boolean" ? !!propertySchema.required : Array.isArray(rootSchema.required) ? rootSchema.required.includes(name) : !!rootSchema.required;
|
|
1429
1440
|
if (this.config.convertedFromSwagger2) return typeof propertySchema.nullable === this.config.Ts.Keyword.Undefined ? isRequired : !propertySchema.nullable;
|
|
1430
1441
|
return isRequired;
|
|
1431
1442
|
};
|
|
1432
1443
|
isNullMissingInType = (schema, type) => {
|
|
1433
1444
|
const { nullable, type: schemaType } = schema || {};
|
|
1434
|
-
return (nullable || !!
|
|
1445
|
+
return (nullable || !!get(schema, "x-nullable") || schemaType === this.config.Ts.Keyword.Null) && typeof type === "string" && !type.includes(` ${this.config.Ts.Keyword.Null}`) && !type.includes(`${this.config.Ts.Keyword.Null} `);
|
|
1435
1446
|
};
|
|
1436
1447
|
safeAddNullToType = (schema, type) => {
|
|
1437
1448
|
if (this.isNullMissingInType(schema, type)) return this.config.Ts.UnionType([type, this.config.Ts.Keyword.Null]);
|
|
@@ -1439,13 +1450,13 @@ var SchemaUtils = class {
|
|
|
1439
1450
|
};
|
|
1440
1451
|
getSchemaPrimitiveType = (rawSchema) => {
|
|
1441
1452
|
const schema = rawSchema || {};
|
|
1442
|
-
if (schema.type) return
|
|
1453
|
+
if (schema.type) return camelCase(schema.type);
|
|
1443
1454
|
if (schema.enum) {
|
|
1444
1455
|
const enumFieldType = typeof schema.enum[0];
|
|
1445
1456
|
if (enumFieldType === this.config.Ts.Keyword.Undefined) return;
|
|
1446
|
-
return
|
|
1457
|
+
return camelCase(enumFieldType);
|
|
1447
1458
|
}
|
|
1448
|
-
if (
|
|
1459
|
+
if (Object.keys(schema.properties || {}).length) return SCHEMA_TYPES$1.OBJECT;
|
|
1449
1460
|
if (schema.items) return SCHEMA_TYPES$1.ARRAY;
|
|
1450
1461
|
return null;
|
|
1451
1462
|
};
|
|
@@ -1458,10 +1469,10 @@ var SchemaUtils = class {
|
|
|
1458
1469
|
};
|
|
1459
1470
|
makeAddRequiredToChildSchema = (parentSchema, childSchema) => {
|
|
1460
1471
|
if (!childSchema) return childSchema;
|
|
1461
|
-
const required =
|
|
1472
|
+
const required = uniq([...this.getRequiredProperties(parentSchema), ...this.getRequiredProperties(childSchema)]);
|
|
1462
1473
|
const refData = this.getSchemaRefType(childSchema);
|
|
1463
1474
|
if (refData) {
|
|
1464
|
-
const existedRequiredKeys =
|
|
1475
|
+
const existedRequiredKeys = Object.keys(refData.rawTypeData?.properties || {}).filter((key) => required.includes(key));
|
|
1465
1476
|
if (!existedRequiredKeys.length) return childSchema;
|
|
1466
1477
|
return {
|
|
1467
1478
|
...childSchema,
|
|
@@ -1469,17 +1480,17 @@ var SchemaUtils = class {
|
|
|
1469
1480
|
};
|
|
1470
1481
|
}
|
|
1471
1482
|
if (childSchema.properties) {
|
|
1472
|
-
const existedRequiredKeys =
|
|
1483
|
+
const existedRequiredKeys = Object.keys(childSchema.properties).filter((key) => required.includes(key));
|
|
1473
1484
|
if (!existedRequiredKeys.length) return childSchema;
|
|
1474
1485
|
return {
|
|
1475
|
-
required:
|
|
1486
|
+
required: uniq([...this.getRequiredProperties(childSchema), ...existedRequiredKeys]),
|
|
1476
1487
|
...childSchema
|
|
1477
1488
|
};
|
|
1478
1489
|
}
|
|
1479
1490
|
return childSchema;
|
|
1480
1491
|
};
|
|
1481
1492
|
filterSchemaContents = (contents, filterFn) => {
|
|
1482
|
-
return
|
|
1493
|
+
return uniq(contents.filter((type) => filterFn(type)));
|
|
1483
1494
|
};
|
|
1484
1495
|
resolveTypeName = (typeName, { suffixes, resolver, prefixes, shouldReserve = true }) => {
|
|
1485
1496
|
if (resolver) return this.config.componentTypeNameResolver.resolve([], (reserved) => {
|
|
@@ -1495,10 +1506,10 @@ var SchemaUtils = class {
|
|
|
1495
1506
|
return SCHEMA_TYPES$1.COMPLEX_UNKNOWN;
|
|
1496
1507
|
};
|
|
1497
1508
|
getInternalSchemaType = (schema) => {
|
|
1498
|
-
if (
|
|
1509
|
+
if (schema.enum && schema.enum.length > 0 || this.getEnumNames(schema) && this.getEnumNames(schema).length > 0) return SCHEMA_TYPES$1.ENUM;
|
|
1499
1510
|
if (schema.discriminator) return SCHEMA_TYPES$1.DISCRIMINATOR;
|
|
1500
1511
|
if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) return SCHEMA_TYPES$1.COMPLEX;
|
|
1501
|
-
if (
|
|
1512
|
+
if (schema.properties && Object.keys(schema.properties).length > 0) return SCHEMA_TYPES$1.OBJECT;
|
|
1502
1513
|
if (schema.type === SCHEMA_TYPES$1.ARRAY) return SCHEMA_TYPES$1.ARRAY;
|
|
1503
1514
|
return SCHEMA_TYPES$1.PRIMITIVE;
|
|
1504
1515
|
};
|
|
@@ -1511,7 +1522,7 @@ var SchemaUtils = class {
|
|
|
1511
1522
|
else {
|
|
1512
1523
|
const primitiveType = this.getSchemaPrimitiveType(schema);
|
|
1513
1524
|
if (primitiveType == null) return this.config.Ts.Keyword.Any;
|
|
1514
|
-
const typeAlias =
|
|
1525
|
+
const typeAlias = get(this.config.primitiveTypes, [primitiveType, schema.format]) || get(this.config.primitiveTypes, [primitiveType, "$default"]) || this.config.primitiveTypes[primitiveType];
|
|
1515
1526
|
if (typeof typeAlias === "function") resultType = typeAlias(schema, this);
|
|
1516
1527
|
else resultType = typeAlias || primitiveType;
|
|
1517
1528
|
}
|
|
@@ -1519,9 +1530,9 @@ var SchemaUtils = class {
|
|
|
1519
1530
|
return this.checkAndAddRequiredKeys(schema, this.safeAddNullToType(schema, resultType));
|
|
1520
1531
|
};
|
|
1521
1532
|
buildTypeNameFromPath = (schemaPath) => {
|
|
1522
|
-
schemaPath =
|
|
1533
|
+
schemaPath = uniq(compact(schemaPath || []));
|
|
1523
1534
|
if (!schemaPath || !schemaPath[0]) return null;
|
|
1524
|
-
return pascalCase(
|
|
1535
|
+
return pascalCase(uniq([schemaPath[0], schemaPath[schemaPath.length - 1]]).join("_"));
|
|
1525
1536
|
};
|
|
1526
1537
|
isConstantSchema(schema) {
|
|
1527
1538
|
return "const" in schema;
|
|
@@ -1564,7 +1575,7 @@ var SchemaParserFabric = class {
|
|
|
1564
1575
|
schemaPath
|
|
1565
1576
|
});
|
|
1566
1577
|
};
|
|
1567
|
-
createSchema = ({ content, linkedSchema = {}, linkedComponent, schemaPath
|
|
1578
|
+
createSchema = ({ content, linkedSchema = {}, linkedComponent, schemaPath, ...otherSchemaProps }) => {
|
|
1568
1579
|
const parser = this.createSchemaParser({
|
|
1569
1580
|
schema: linkedComponent || linkedSchema,
|
|
1570
1581
|
schemaPath
|
|
@@ -1612,8 +1623,7 @@ var SchemaParserFabric = class {
|
|
|
1612
1623
|
|
|
1613
1624
|
//#endregion
|
|
1614
1625
|
//#region src/util/id.ts
|
|
1615
|
-
const
|
|
1616
|
-
const generateId = nanoid.customAlphabet(ALPHABET, 12);
|
|
1626
|
+
const generateId = () => crypto.randomUUID();
|
|
1617
1627
|
|
|
1618
1628
|
//#endregion
|
|
1619
1629
|
//#region src/schema-routes/util/specific-arg-name-resolver.ts
|
|
@@ -1658,7 +1668,7 @@ var SchemaRoutes = class {
|
|
|
1658
1668
|
this.typeNameFormatter = typeNameFormatter;
|
|
1659
1669
|
this.schemaComponentsMap = schemaComponentsMap;
|
|
1660
1670
|
this.templatesWorker = templatesWorker;
|
|
1661
|
-
this.FORM_DATA_TYPES =
|
|
1671
|
+
this.FORM_DATA_TYPES = uniq([this.schemaUtils.getSchemaType({
|
|
1662
1672
|
type: "string",
|
|
1663
1673
|
format: "file"
|
|
1664
1674
|
}), this.schemaUtils.getSchemaType({
|
|
@@ -1666,49 +1676,50 @@ var SchemaRoutes = class {
|
|
|
1666
1676
|
format: "binary"
|
|
1667
1677
|
})]);
|
|
1668
1678
|
}
|
|
1669
|
-
createRequestsMap = (
|
|
1670
|
-
const parameters =
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1679
|
+
createRequestsMap = (routesByMethod) => {
|
|
1680
|
+
const parameters = get(routesByMethod, "parameters");
|
|
1681
|
+
const result = {};
|
|
1682
|
+
for (const [method, requestInfo] of Object.entries(routesByMethod)) {
|
|
1683
|
+
if (method.startsWith("x-") || ["parameters", "$ref"].includes(method)) continue;
|
|
1684
|
+
result[method] = {
|
|
1674
1685
|
...requestInfo,
|
|
1675
|
-
parameters:
|
|
1686
|
+
parameters: compact([...parameters || [], ...requestInfo.parameters || []])
|
|
1676
1687
|
};
|
|
1677
|
-
|
|
1678
|
-
|
|
1688
|
+
}
|
|
1689
|
+
return result;
|
|
1679
1690
|
};
|
|
1680
|
-
parseRouteName = (
|
|
1681
|
-
const routeName = this.config.hooks.onPreBuildRoutePath(
|
|
1691
|
+
parseRouteName = (rawRoute) => {
|
|
1692
|
+
const routeName = this.config.hooks.onPreBuildRoutePath(rawRoute) || rawRoute;
|
|
1682
1693
|
const pathParamMatches = (routeName || "").match(/({[\w[\\\]^`][-_.\w]*})|(:[\w[\\\]^`][-_.\w]*:?)/g);
|
|
1683
|
-
const pathParams =
|
|
1694
|
+
const pathParams = [];
|
|
1695
|
+
for (const match of pathParamMatches || []) {
|
|
1684
1696
|
const paramName = match.replace(/\{|\}|:/g, "");
|
|
1685
|
-
if (!paramName)
|
|
1697
|
+
if (!paramName) continue;
|
|
1686
1698
|
if (paramName.includes("-")) consola.warn("wrong path param name", paramName);
|
|
1687
|
-
pathParams
|
|
1699
|
+
pathParams.push({
|
|
1688
1700
|
$match: match,
|
|
1689
|
-
name:
|
|
1701
|
+
name: camelCase(paramName),
|
|
1690
1702
|
required: true,
|
|
1691
1703
|
type: "string",
|
|
1692
1704
|
description: "",
|
|
1693
1705
|
schema: { type: "string" },
|
|
1694
1706
|
in: "path"
|
|
1695
1707
|
});
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
return fixedRoute$1.replace(pathParam.$match, `\${${insertion}}`);
|
|
1708
|
+
}
|
|
1709
|
+
let fixedRoute = pathParams.reduce((fixedRoute, pathParam, i, arr) => {
|
|
1710
|
+
const insertion = this.config.hooks.onInsertPathParam(pathParam.name, i, arr, fixedRoute) || pathParam.name;
|
|
1711
|
+
return fixedRoute.replace(pathParam.$match, `\${${insertion}}`);
|
|
1701
1712
|
}, routeName || "");
|
|
1702
1713
|
const queryParamMatches = fixedRoute.match(/(\{\?.*\})/g);
|
|
1703
1714
|
const queryParams = [];
|
|
1704
1715
|
if (queryParamMatches?.length) {
|
|
1705
1716
|
for (const match of queryParamMatches) fixedRoute = fixedRoute.replace(match, "");
|
|
1706
|
-
const paramNames =
|
|
1717
|
+
const paramNames = uniq(queryParamMatches.join(",").replace(/(\{\?)|(\})|\s/g, "").split(","));
|
|
1707
1718
|
for (const paramName of paramNames) {
|
|
1708
|
-
if (paramName.includes("-")) consola.warn("wrong query param name", paramName);
|
|
1719
|
+
if (typeof paramName === "string" && paramName.includes("-")) consola.warn("wrong query param name", paramName);
|
|
1709
1720
|
queryParams.push({
|
|
1710
1721
|
$match: paramName,
|
|
1711
|
-
name:
|
|
1722
|
+
name: typeof paramName === "string" ? camelCase(paramName) : camelCase(String(paramName)),
|
|
1712
1723
|
required: true,
|
|
1713
1724
|
type: "string",
|
|
1714
1725
|
description: "",
|
|
@@ -1718,7 +1729,7 @@ var SchemaRoutes = class {
|
|
|
1718
1729
|
}
|
|
1719
1730
|
}
|
|
1720
1731
|
const result = {
|
|
1721
|
-
originalRoute:
|
|
1732
|
+
originalRoute: rawRoute || "",
|
|
1722
1733
|
route: fixedRoute,
|
|
1723
1734
|
pathParams,
|
|
1724
1735
|
queryParams
|
|
@@ -1735,7 +1746,7 @@ var SchemaRoutes = class {
|
|
|
1735
1746
|
formData: [],
|
|
1736
1747
|
cookie: []
|
|
1737
1748
|
};
|
|
1738
|
-
|
|
1749
|
+
for (const parameter of parameters || []) {
|
|
1739
1750
|
const refTypeInfo = this.schemaParserFabric.schemaUtils.getSchemaRefType(parameter);
|
|
1740
1751
|
let routeParam = null;
|
|
1741
1752
|
if (refTypeInfo?.rawTypeData.in && refTypeInfo.rawTypeData) {
|
|
@@ -1746,7 +1757,7 @@ var SchemaRoutes = class {
|
|
|
1746
1757
|
};
|
|
1747
1758
|
if (parameter?.required && !routeParam.required) routeParam.required = parameter.required;
|
|
1748
1759
|
} else {
|
|
1749
|
-
if (!parameter.in)
|
|
1760
|
+
if (!parameter.in) continue;
|
|
1750
1761
|
if (!routeParams[parameter.in]) routeParams[parameter.in] = [];
|
|
1751
1762
|
routeParam = {
|
|
1752
1763
|
...parameter,
|
|
@@ -1754,16 +1765,19 @@ var SchemaRoutes = class {
|
|
|
1754
1765
|
};
|
|
1755
1766
|
}
|
|
1756
1767
|
if (routeParam.in === "path") {
|
|
1757
|
-
if (!routeParam.name)
|
|
1758
|
-
routeParam.name =
|
|
1768
|
+
if (!routeParam.name) continue;
|
|
1769
|
+
routeParam.name = camelCase(routeParam.name);
|
|
1759
1770
|
}
|
|
1760
|
-
|
|
1761
|
-
}
|
|
1771
|
+
routeParams[routeParam.in].push(routeParam);
|
|
1772
|
+
}
|
|
1762
1773
|
for (const pathParam of pathParamsFromRouteName) if (!routeParams.path.some((parameter) => parameter.name === pathParam.name)) routeParams.path.push(pathParam);
|
|
1763
1774
|
for (const queryParam of queryParamsFromRouteName) if (!routeParams.query.some((parameter) => parameter.name === queryParam.name)) routeParams.query.push(queryParam);
|
|
1764
1775
|
return routeParams;
|
|
1765
1776
|
};
|
|
1766
|
-
getContentTypes = (requestInfo, extraContentTypes) =>
|
|
1777
|
+
getContentTypes = (requestInfo, extraContentTypes) => {
|
|
1778
|
+
const requestInfoArray = Array.isArray(requestInfo) ? requestInfo : Object.values(requestInfo || {});
|
|
1779
|
+
return uniq(compact([...extraContentTypes || [], ...flattenDeep(requestInfoArray.map((requestInfoData) => requestInfoData && Object.keys(requestInfoData?.content || {})))]));
|
|
1780
|
+
};
|
|
1767
1781
|
getContentKind = (contentTypes) => {
|
|
1768
1782
|
if (contentTypes.includes("application/vnd.api+json")) return CONTENT_KIND.JSON_API;
|
|
1769
1783
|
if (contentTypes.some((contentType) => contentType.startsWith("application/json")) || contentTypes.some((contentType) => contentType.endsWith("+json"))) return CONTENT_KIND.JSON;
|
|
@@ -1775,7 +1789,7 @@ var SchemaRoutes = class {
|
|
|
1775
1789
|
};
|
|
1776
1790
|
isSuccessStatus = (status) => this.config.defaultResponseAsSuccess && status === "default" || +status >= this.config.successResponseStatusRange[0] && +status <= this.config.successResponseStatusRange[1] || status === "2xx";
|
|
1777
1791
|
getSchemaFromRequestType = (requestInfo) => {
|
|
1778
|
-
const content =
|
|
1792
|
+
const content = get(requestInfo, "content");
|
|
1779
1793
|
if (!content) return null;
|
|
1780
1794
|
for (const dataType in content) if (content[dataType]?.schema) return {
|
|
1781
1795
|
...content[dataType].schema,
|
|
@@ -1789,13 +1803,13 @@ var SchemaRoutes = class {
|
|
|
1789
1803
|
if (schema) {
|
|
1790
1804
|
const content = this.schemaParserFabric.getInlineParseContent(schema, typeName, [operationId]);
|
|
1791
1805
|
const foundedSchemaByName = parsedSchemas.find((parsedSchema) => this.typeNameFormatter.format(parsedSchema.name) === content);
|
|
1792
|
-
const foundSchemaByContent = parsedSchemas.find((parsedSchema) =>
|
|
1806
|
+
const foundSchemaByContent = parsedSchemas.find((parsedSchema) => isEqual(parsedSchema.content, content));
|
|
1793
1807
|
const foundSchema = foundedSchemaByName || foundSchemaByContent;
|
|
1794
1808
|
return foundSchema ? this.typeNameFormatter.format(foundSchema.name) : content;
|
|
1795
1809
|
}
|
|
1796
1810
|
if (refTypeInfo) {
|
|
1797
1811
|
const typeNameWithoutOpId = refTypeInfo.typeName.replace(operationId, "");
|
|
1798
|
-
if (parsedSchemas.find((schema
|
|
1812
|
+
if (parsedSchemas.find((schema) => schema.name === typeNameWithoutOpId)) return this.typeNameFormatter.format(typeNameWithoutOpId);
|
|
1799
1813
|
switch (refTypeInfo.componentName) {
|
|
1800
1814
|
case "schemas": return this.typeNameFormatter.format(refTypeInfo.typeName);
|
|
1801
1815
|
case "responses":
|
|
@@ -1805,23 +1819,27 @@ var SchemaRoutes = class {
|
|
|
1805
1819
|
}
|
|
1806
1820
|
return defaultType || this.config.Ts.Keyword.Any;
|
|
1807
1821
|
};
|
|
1808
|
-
getRequestInfoTypes = ({ requestInfos, parsedSchemas, operationId, defaultType }) =>
|
|
1809
|
-
const
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1822
|
+
getRequestInfoTypes = ({ requestInfos, parsedSchemas, operationId, defaultType }) => {
|
|
1823
|
+
const result = [];
|
|
1824
|
+
for (const [status, requestInfo] of Object.entries(requestInfos || {})) {
|
|
1825
|
+
const contentTypes = this.getContentTypes([requestInfo], operationId);
|
|
1826
|
+
result.push({
|
|
1827
|
+
...requestInfo || {},
|
|
1828
|
+
contentTypes,
|
|
1829
|
+
contentKind: this.getContentKind(contentTypes),
|
|
1830
|
+
type: this.schemaParserFabric.schemaUtils.safeAddNullToType(requestInfo, this.getTypeFromRequestInfo({
|
|
1831
|
+
requestInfo,
|
|
1832
|
+
parsedSchemas,
|
|
1833
|
+
operationId,
|
|
1834
|
+
defaultType
|
|
1835
|
+
})),
|
|
1836
|
+
description: this.schemaParserFabric.schemaFormatters.formatDescription(requestInfo.description || "", true),
|
|
1837
|
+
status: Number.isNaN(+status) ? status : +status,
|
|
1838
|
+
isSuccess: this.isSuccessStatus(status)
|
|
1839
|
+
});
|
|
1840
|
+
}
|
|
1841
|
+
return result;
|
|
1842
|
+
};
|
|
1825
1843
|
getResponseBodyInfo = (routeInfo, parsedSchemas) => {
|
|
1826
1844
|
const { produces, operationId, responses } = routeInfo;
|
|
1827
1845
|
const contentTypes = this.getContentTypes(responses, [...produces || [], routeInfo["x-accepts"]]);
|
|
@@ -1930,13 +1948,12 @@ var SchemaRoutes = class {
|
|
|
1930
1948
|
};
|
|
1931
1949
|
return acc;
|
|
1932
1950
|
}, {});
|
|
1933
|
-
const fixedQueryParams =
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
}, {});
|
|
1951
|
+
const fixedQueryParams = {};
|
|
1952
|
+
const queryObjectProperties = get(queryObjectSchema, "properties") || {};
|
|
1953
|
+
for (const [name, property] of Object.entries(queryObjectProperties)) if (name && typeof property === "object") fixedQueryParams[name] = {
|
|
1954
|
+
...property,
|
|
1955
|
+
in: "query"
|
|
1956
|
+
};
|
|
1940
1957
|
const schema = {
|
|
1941
1958
|
...queryObjectSchema,
|
|
1942
1959
|
properties: {
|
|
@@ -1979,7 +1996,7 @@ var SchemaRoutes = class {
|
|
|
1979
1996
|
successResponse.schema.contentKind = contentKind;
|
|
1980
1997
|
if (successResponse.schema.typeData) successResponse.schema.typeData.isExtractedResponseBody = true;
|
|
1981
1998
|
successResponse.type = this.schemaParserFabric.getInlineParseContent({ $ref: successResponse.schema.$ref });
|
|
1982
|
-
if (idx > -1)
|
|
1999
|
+
if (idx > -1) Object.assign(responseBodyInfo.responses[idx], {
|
|
1983
2000
|
...successResponse.schema,
|
|
1984
2001
|
type: successResponse.type
|
|
1985
2002
|
});
|
|
@@ -1992,18 +2009,18 @@ var SchemaRoutes = class {
|
|
|
1992
2009
|
suffixes: this.config.extractingOptions.responseErrorSuffix,
|
|
1993
2010
|
resolver: this.config.extractingOptions.responseErrorNameResolver
|
|
1994
2011
|
});
|
|
1995
|
-
const errorSchemas = responseBodyInfo.error.schemas.map(this.getSchemaFromRequestType)
|
|
2012
|
+
const errorSchemas = compact(responseBodyInfo.error.schemas.map(this.getSchemaFromRequestType));
|
|
1996
2013
|
if (!errorSchemas.length) return;
|
|
1997
2014
|
const schema = this.schemaParserFabric.parseSchema({
|
|
1998
2015
|
oneOf: errorSchemas,
|
|
1999
|
-
title: errorSchemas.map((schema
|
|
2000
|
-
description: errorSchemas.map((schema
|
|
2016
|
+
title: compact(errorSchemas.map((schema) => schema.title)).join(" "),
|
|
2017
|
+
description: compact(errorSchemas.map((schema) => schema.description)).join("\n")
|
|
2001
2018
|
}, null, [routeInfo.operationId]);
|
|
2002
2019
|
const component = this.schemaComponentsMap.createComponent(this.schemaComponentsMap.createRef([
|
|
2003
2020
|
"components",
|
|
2004
2021
|
"schemas",
|
|
2005
2022
|
typeName
|
|
2006
|
-
]),
|
|
2023
|
+
]), schema);
|
|
2007
2024
|
responseBodyInfo.error.schemas = [component];
|
|
2008
2025
|
if (component.typeData) component.typeData.isExtractedResponseError = true;
|
|
2009
2026
|
responseBodyInfo.error.type = this.typeNameFormatter.format(component.typeName);
|
|
@@ -2031,11 +2048,11 @@ var SchemaRoutes = class {
|
|
|
2031
2048
|
parseRouteInfo = (rawRouteName, routeInfo, method, usageSchema, parsedSchemas) => {
|
|
2032
2049
|
const { security: globalSecurity } = usageSchema;
|
|
2033
2050
|
const { moduleNameIndex, moduleNameFirstTag, extractRequestParams } = this.config;
|
|
2034
|
-
const { operationId, requestBody, security, parameters, summary, description
|
|
2051
|
+
const { operationId, requestBody, security, parameters, summary, description, tags, responses, requestBodyName, produces, consumes, ...otherInfo } = routeInfo;
|
|
2035
2052
|
const { route, pathParams: pathParamsFromRouteName, queryParams: queryParamsFromRouteName } = this.parseRouteName(rawRouteName);
|
|
2036
2053
|
const routeId = generateId();
|
|
2037
2054
|
const firstTag = tags && tags.length > 0 ? tags[0] : null;
|
|
2038
|
-
const moduleName = moduleNameFirstTag && firstTag ?
|
|
2055
|
+
const moduleName = moduleNameFirstTag && firstTag ? camelCase(firstTag) : camelCase(compact(route.split("/"))[moduleNameIndex] || "");
|
|
2039
2056
|
let hasSecurity = !!globalSecurity?.length;
|
|
2040
2057
|
if (security) hasSecurity = security.length > 0;
|
|
2041
2058
|
const routeParams = this.getRouteParams(routeInfo, pathParamsFromRouteName, queryParamsFromRouteName);
|
|
@@ -2055,7 +2072,7 @@ var SchemaRoutes = class {
|
|
|
2055
2072
|
route: rawRouteName,
|
|
2056
2073
|
moduleName,
|
|
2057
2074
|
responsesTypes: responseBodyInfo.responses,
|
|
2058
|
-
description
|
|
2075
|
+
description,
|
|
2059
2076
|
tags,
|
|
2060
2077
|
summary,
|
|
2061
2078
|
responses,
|
|
@@ -2152,7 +2169,7 @@ var SchemaRoutes = class {
|
|
|
2152
2169
|
};
|
|
2153
2170
|
attachSchema = ({ usageSchema, parsedSchemas }) => {
|
|
2154
2171
|
this.config.routeNameDuplicatesMap.clear();
|
|
2155
|
-
const pathsEntries =
|
|
2172
|
+
const pathsEntries = Object.entries(usageSchema.paths || {});
|
|
2156
2173
|
for (const [rawRouteName, routeInfoByMethodsMap] of pathsEntries) {
|
|
2157
2174
|
const routeInfosMap = this.createRequestsMap(routeInfoByMethodsMap);
|
|
2158
2175
|
for (const [method, routeInfo] of Object.entries(routeInfosMap)) {
|
|
@@ -2176,37 +2193,36 @@ var SchemaRoutes = class {
|
|
|
2176
2193
|
} else modules.$outOfModule.push(route);
|
|
2177
2194
|
return modules;
|
|
2178
2195
|
}, { $outOfModule: [] });
|
|
2179
|
-
const routeGroups =
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2196
|
+
const routeGroups = {
|
|
2197
|
+
outOfModule: void 0,
|
|
2198
|
+
combined: void 0
|
|
2199
|
+
};
|
|
2200
|
+
for (const [moduleName, routesGroup] of Object.entries(groupedRoutes)) if (moduleName === "$outOfModule") routeGroups.outOfModule = routesGroup;
|
|
2201
|
+
else {
|
|
2202
|
+
if (!routeGroups.combined) routeGroups.combined = [];
|
|
2203
|
+
routeGroups.combined.push({
|
|
2204
|
+
moduleName,
|
|
2205
|
+
routes: routesGroup.map((route) => {
|
|
2206
|
+
const { original: originalName, usage: usageName } = route.routeName;
|
|
2207
|
+
if (routesGroup.length > 1 && usageName !== originalName && !routesGroup.some(({ routeName, id }) => id !== route.id && originalName === routeName.original)) return {
|
|
2208
|
+
...route,
|
|
2209
|
+
routeName: {
|
|
2210
|
+
...route.routeName,
|
|
2211
|
+
usage: originalName
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
return route;
|
|
2215
|
+
})
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2200
2218
|
if (this.config.sortRoutes) {
|
|
2201
2219
|
if (routeGroups.outOfModule) routeGroups.outOfModule = this.sortRoutes(routeGroups.outOfModule);
|
|
2202
|
-
if (routeGroups.combined)
|
|
2203
|
-
routeGroup.routes = this.sortRoutes(routeGroup.routes);
|
|
2204
|
-
});
|
|
2220
|
+
if (routeGroups.combined) for (const routeGroup of routeGroups.combined) routeGroup.routes = this.sortRoutes(routeGroup.routes);
|
|
2205
2221
|
}
|
|
2206
2222
|
return routeGroups;
|
|
2207
2223
|
};
|
|
2208
2224
|
sortRoutes = (routes) => {
|
|
2209
|
-
return
|
|
2225
|
+
return routes.slice().sort((routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage));
|
|
2210
2226
|
};
|
|
2211
2227
|
};
|
|
2212
2228
|
|
|
@@ -2221,8 +2237,8 @@ var SchemaWalker = class {
|
|
|
2221
2237
|
this.config = config;
|
|
2222
2238
|
this.swaggerSchemaResolver = swaggerSchemaResolver;
|
|
2223
2239
|
}
|
|
2224
|
-
addSchema = (name
|
|
2225
|
-
this.schemas.set(name
|
|
2240
|
+
addSchema = (name, schema) => {
|
|
2241
|
+
this.schemas.set(name, structuredClone(schema));
|
|
2226
2242
|
};
|
|
2227
2243
|
_isLocalRef = (ref) => {
|
|
2228
2244
|
return ref.startsWith("#");
|
|
@@ -2231,8 +2247,7 @@ var SchemaWalker = class {
|
|
|
2231
2247
|
return ref.startsWith("http://") || ref.startsWith("https://");
|
|
2232
2248
|
};
|
|
2233
2249
|
_getRefDataFromSchema = (schema, ref) => {
|
|
2234
|
-
const
|
|
2235
|
-
const refData = lodash.get(schema, path$2);
|
|
2250
|
+
const refData = get(schema, ref.replace("#", "").split("/"));
|
|
2236
2251
|
if (refData) this.caches.set(ref, refData);
|
|
2237
2252
|
return refData;
|
|
2238
2253
|
};
|
|
@@ -2245,14 +2260,14 @@ var Request = class {
|
|
|
2245
2260
|
constructor(config) {
|
|
2246
2261
|
this.config = config;
|
|
2247
2262
|
}
|
|
2248
|
-
async download({ url
|
|
2263
|
+
async download({ url, authToken, ...options }) {
|
|
2249
2264
|
const requestOptions = {};
|
|
2250
2265
|
if (authToken) requestOptions.headers = { Authorization: authToken };
|
|
2251
|
-
|
|
2266
|
+
merge(merge(requestOptions, options), this.config.requestOptions || {});
|
|
2252
2267
|
try {
|
|
2253
|
-
return await (await fetch(url
|
|
2268
|
+
return await (await fetch(url, requestOptions)).text();
|
|
2254
2269
|
} catch (error) {
|
|
2255
|
-
const message = `error while fetching data from URL "${url
|
|
2270
|
+
const message = `error while fetching data from URL "${url}"`;
|
|
2256
2271
|
consola.error(message, error);
|
|
2257
2272
|
return message;
|
|
2258
2273
|
}
|
|
@@ -2271,21 +2286,21 @@ var SwaggerSchemaResolver = class {
|
|
|
2271
2286
|
this.request = new Request(config);
|
|
2272
2287
|
}
|
|
2273
2288
|
async create() {
|
|
2274
|
-
const { spec, patch, input, url
|
|
2289
|
+
const { spec, patch, input, url, authorizationToken } = this.config;
|
|
2275
2290
|
if (spec) return await this.convertSwaggerObject(spec, { patch });
|
|
2276
|
-
const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url
|
|
2291
|
+
const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url, authorizationToken);
|
|
2277
2292
|
const swaggerSchemaObject = this.processSwaggerSchemaFile(swaggerSchemaFile);
|
|
2278
2293
|
return await this.convertSwaggerObject(swaggerSchemaObject, { patch });
|
|
2279
2294
|
}
|
|
2280
2295
|
convertSwaggerObject(swaggerSchema, converterOptions) {
|
|
2281
2296
|
return new Promise((resolve) => {
|
|
2282
2297
|
const result = structuredClone(swaggerSchema);
|
|
2283
|
-
result.info =
|
|
2298
|
+
result.info = merge({
|
|
2284
2299
|
title: "No title",
|
|
2285
2300
|
version: ""
|
|
2286
|
-
}, result.info);
|
|
2301
|
+
}, result.info || {});
|
|
2287
2302
|
if (!Object.hasOwn(result, "openapi")) {
|
|
2288
|
-
result.paths =
|
|
2303
|
+
result.paths = merge({}, result.paths || {});
|
|
2289
2304
|
swagger2openapi.convertObj(result, {
|
|
2290
2305
|
...converterOptions,
|
|
2291
2306
|
resolveInternal: true,
|
|
@@ -2293,7 +2308,7 @@ var SwaggerSchemaResolver = class {
|
|
|
2293
2308
|
refSiblings: "preserve",
|
|
2294
2309
|
rbname: "requestBodyName"
|
|
2295
2310
|
}, (err, options) => {
|
|
2296
|
-
const parsedSwaggerSchema =
|
|
2311
|
+
const parsedSwaggerSchema = get(err, "options.openapi") ?? get(options, "openapi");
|
|
2297
2312
|
if (!parsedSwaggerSchema && err) throw err;
|
|
2298
2313
|
this.config.update({ convertedFromSwagger2: true });
|
|
2299
2314
|
resolve({
|
|
@@ -2328,23 +2343,21 @@ var SwaggerSchemaResolver = class {
|
|
|
2328
2343
|
}
|
|
2329
2344
|
}
|
|
2330
2345
|
fixSwaggerSchema({ usageSchema, originalSchema }) {
|
|
2331
|
-
const usagePaths =
|
|
2332
|
-
const originalPaths =
|
|
2333
|
-
|
|
2334
|
-
const originalPathObject =
|
|
2335
|
-
|
|
2336
|
-
const originalRouteInfo =
|
|
2337
|
-
const usageRouteParams =
|
|
2338
|
-
const originalRouteParams =
|
|
2346
|
+
const usagePaths = get(usageSchema, "paths") || {};
|
|
2347
|
+
const originalPaths = get(originalSchema, "paths") || {};
|
|
2348
|
+
for (const [route, usagePathObject] of Object.entries(usagePaths)) {
|
|
2349
|
+
const originalPathObject = get(originalPaths, route) || {};
|
|
2350
|
+
for (const [methodName, usageRouteInfo] of Object.entries(usagePathObject)) {
|
|
2351
|
+
const originalRouteInfo = get(originalPathObject, methodName) || {};
|
|
2352
|
+
const usageRouteParams = get(usageRouteInfo, "parameters") || [];
|
|
2353
|
+
const originalRouteParams = get(originalRouteInfo, "parameters") || [];
|
|
2339
2354
|
if (typeof usageRouteInfo === "object") {
|
|
2340
|
-
usageRouteInfo.consumes =
|
|
2341
|
-
usageRouteInfo.produces =
|
|
2355
|
+
usageRouteInfo.consumes = uniq(compact([...usageRouteInfo.consumes || [], ...originalRouteInfo.consumes || []]));
|
|
2356
|
+
usageRouteInfo.produces = uniq(compact([...usageRouteInfo.produces || [], ...originalRouteInfo.produces || []]));
|
|
2342
2357
|
}
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
});
|
|
2347
|
-
});
|
|
2358
|
+
for (const originalRouteParam of originalRouteParams) if (!usageRouteParams.find((param) => originalRouteParam.in === param.in && originalRouteParam.name === param.name)) usageRouteParams.push(originalRouteParam);
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2348
2361
|
}
|
|
2349
2362
|
};
|
|
2350
2363
|
|
|
@@ -2364,10 +2377,10 @@ var TemplatesWorker = class {
|
|
|
2364
2377
|
if (this.config.silent) consola.level = 0;
|
|
2365
2378
|
}
|
|
2366
2379
|
getTemplatePaths = (config) => {
|
|
2367
|
-
const __dirname
|
|
2368
|
-
const baseTemplatesPath = path$1.resolve(__dirname
|
|
2369
|
-
const defaultTemplatesPath = path$1.resolve(__dirname
|
|
2370
|
-
const modularTemplatesPath = path$1.resolve(__dirname
|
|
2380
|
+
const __dirname = path$1.dirname(url$1.fileURLToPath(import.meta.url));
|
|
2381
|
+
const baseTemplatesPath = path$1.resolve(__dirname, "../templates/base");
|
|
2382
|
+
const defaultTemplatesPath = path$1.resolve(__dirname, "../templates/default");
|
|
2383
|
+
const modularTemplatesPath = path$1.resolve(__dirname, "../templates/modular");
|
|
2371
2384
|
return {
|
|
2372
2385
|
base: baseTemplatesPath,
|
|
2373
2386
|
default: defaultTemplatesPath,
|
|
@@ -2376,7 +2389,7 @@ var TemplatesWorker = class {
|
|
|
2376
2389
|
custom: config.templates && path$1.resolve(process.cwd(), config.templates)
|
|
2377
2390
|
};
|
|
2378
2391
|
};
|
|
2379
|
-
cropExtension = (path
|
|
2392
|
+
cropExtension = (path) => this.config.templateExtensions.reduce((path, ext) => path.endsWith(ext) ? path.replace(ext, "") : path, path);
|
|
2380
2393
|
getTemplateFullPath = (path_, fileName) => {
|
|
2381
2394
|
const raw = path$1.resolve(path_, "./", this.cropExtension(fileName));
|
|
2382
2395
|
return this.config.templateExtensions.map((extension) => `${raw}${extension}`).find((variant) => !!this.fileSystem.pathIsExist(variant));
|
|
@@ -2385,39 +2398,39 @@ var TemplatesWorker = class {
|
|
|
2385
2398
|
if (packageOrPath.startsWith("./") || packageOrPath.startsWith("../")) return require(path$1.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
|
|
2386
2399
|
return require(packageOrPath);
|
|
2387
2400
|
};
|
|
2388
|
-
getTemplate = (name
|
|
2401
|
+
getTemplate = (name, fileName, path) => {
|
|
2389
2402
|
const { templatePaths } = this.config;
|
|
2390
|
-
if (path
|
|
2403
|
+
if (path) return this.fileSystem.getFileContent(path);
|
|
2391
2404
|
if (!fileName) return "";
|
|
2392
2405
|
const customFullPath = templatePaths.custom && this.getTemplateFullPath(templatePaths.custom, fileName);
|
|
2393
2406
|
let fileContent = customFullPath && this.fileSystem.getFileContent(customFullPath);
|
|
2394
2407
|
if (fileContent) {
|
|
2395
|
-
consola.info(`"${name
|
|
2408
|
+
consola.info(`"${name.toLowerCase()}" template found in "${templatePaths.custom}"`);
|
|
2396
2409
|
return fileContent;
|
|
2397
2410
|
}
|
|
2398
2411
|
const baseFullPath = this.getTemplateFullPath(templatePaths.base, fileName);
|
|
2399
2412
|
if (baseFullPath) fileContent = this.fileSystem.getFileContent(baseFullPath);
|
|
2400
|
-
else if (templatePaths.custom) consola.warn("Code generator will use the default template:", `"${name
|
|
2401
|
-
else consola.info(`Code generator will use the default template for "${name
|
|
2413
|
+
else if (templatePaths.custom) consola.warn("Code generator will use the default template:", `"${name.toLowerCase()}"`, "template not found in", `"${templatePaths.custom}"`);
|
|
2414
|
+
else consola.info(`Code generator will use the default template for "${name.toLowerCase()}"`);
|
|
2402
2415
|
const originalFullPath = this.getTemplateFullPath(templatePaths.original, fileName);
|
|
2403
2416
|
if (originalFullPath) fileContent = this.fileSystem.getFileContent(originalFullPath);
|
|
2404
2417
|
return fileContent;
|
|
2405
2418
|
};
|
|
2406
2419
|
getTemplates = ({ templatePaths }) => {
|
|
2407
2420
|
if (templatePaths.custom) consola.info(`try to read templates from directory "${templatePaths.custom}"`);
|
|
2408
|
-
return
|
|
2421
|
+
return this.config.templateInfos.reduce((acc, { name, fileName }) => ({
|
|
2409
2422
|
...acc,
|
|
2410
|
-
[name
|
|
2423
|
+
[name]: this.getTemplate(name, fileName)
|
|
2411
2424
|
}), {});
|
|
2412
2425
|
};
|
|
2413
|
-
findTemplateWithExt = (path
|
|
2414
|
-
const raw = this.cropExtension(path
|
|
2426
|
+
findTemplateWithExt = (path) => {
|
|
2427
|
+
const raw = this.cropExtension(path);
|
|
2415
2428
|
return this.config.templateExtensions.map((extension) => `${raw}${extension}`).find((variant) => this.fileSystem.pathIsExist(variant));
|
|
2416
2429
|
};
|
|
2417
2430
|
getTemplateContent = (path_) => {
|
|
2418
|
-
const foundTemplatePathKey =
|
|
2431
|
+
const foundTemplatePathKey = Object.keys(this.config.templatePaths).find((key) => path_.startsWith(`@${key}`));
|
|
2419
2432
|
if (foundTemplatePathKey) {
|
|
2420
|
-
const rawPath = path$1.resolve(path_.replace(`@${foundTemplatePathKey}`,
|
|
2433
|
+
const rawPath = path$1.resolve(path_.replace(`@${foundTemplatePathKey}`, get(this.config.templatePaths, foundTemplatePathKey)));
|
|
2421
2434
|
const fixedPath = this.findTemplateWithExt(rawPath);
|
|
2422
2435
|
if (fixedPath) return this.fileSystem.getFileContent(fixedPath);
|
|
2423
2436
|
}
|
|
@@ -2432,7 +2445,7 @@ var TemplatesWorker = class {
|
|
|
2432
2445
|
return eta.render(eta.compile(template, { async: false }), {
|
|
2433
2446
|
...this.getRenderTemplateData(),
|
|
2434
2447
|
...configuration
|
|
2435
|
-
}, { includeFile: (path
|
|
2448
|
+
}, { includeFile: (path, configuration) => this.renderTemplate(this.getTemplateContent(path), configuration) });
|
|
2436
2449
|
};
|
|
2437
2450
|
};
|
|
2438
2451
|
|
|
@@ -2499,51 +2512,50 @@ var TypeNameFormatter = class {
|
|
|
2499
2512
|
constructor(config) {
|
|
2500
2513
|
this.config = config;
|
|
2501
2514
|
}
|
|
2502
|
-
format = (name
|
|
2515
|
+
format = (name, options = {}) => {
|
|
2503
2516
|
const schemaType = options.type ?? "type-name";
|
|
2504
2517
|
const typePrefix = schemaType === "enum-key" ? this.config.enumKeyPrefix : this.config.typePrefix;
|
|
2505
2518
|
const typeSuffix = schemaType === "enum-key" ? this.config.enumKeySuffix : this.config.typeSuffix;
|
|
2506
|
-
const hashKey = `${typePrefix}_${name
|
|
2507
|
-
if (typeof name
|
|
2508
|
-
consola.warn("wrong model name", name
|
|
2509
|
-
return name
|
|
2519
|
+
const hashKey = `${typePrefix}_${name}_${typeSuffix}`;
|
|
2520
|
+
if (typeof name !== "string") {
|
|
2521
|
+
consola.warn("wrong model name", name);
|
|
2522
|
+
return name;
|
|
2510
2523
|
}
|
|
2511
|
-
if (/^(?!\d)([A-Z0-9_]{1,})$/g.test(name
|
|
2524
|
+
if (/^(?!\d)([A-Z0-9_]{1,})$/g.test(name)) return compact([
|
|
2512
2525
|
typePrefix,
|
|
2513
|
-
name
|
|
2526
|
+
name,
|
|
2514
2527
|
typeSuffix
|
|
2515
2528
|
]).join("_");
|
|
2516
2529
|
if (this.formattedModelNamesMap.has(hashKey)) return this.formattedModelNamesMap.get(hashKey);
|
|
2517
|
-
const
|
|
2518
|
-
const
|
|
2519
|
-
const formattedResultName = this.config.hooks.onFormatTypeName(formattedName, name$1, schemaType) || formattedName;
|
|
2530
|
+
const formattedName = startCase(`${typePrefix}_${this.fixModelName(name, { type: schemaType })}_${typeSuffix}`).replace(/\s/g, "");
|
|
2531
|
+
const formattedResultName = this.config.hooks.onFormatTypeName(formattedName, name, schemaType) || formattedName;
|
|
2520
2532
|
this.formattedModelNamesMap.set(hashKey, formattedResultName);
|
|
2521
2533
|
return formattedResultName;
|
|
2522
2534
|
};
|
|
2523
|
-
isValidName = (name
|
|
2524
|
-
fixModelName = (name
|
|
2525
|
-
if (!this.isValidName(name
|
|
2526
|
-
if (!/^[a-zA-Z_$]/g.test(name
|
|
2527
|
-
if (name
|
|
2528
|
-
if (name
|
|
2535
|
+
isValidName = (name) => /^([A-Za-z$_]{1,})$/g.test(name);
|
|
2536
|
+
fixModelName = (name, options) => {
|
|
2537
|
+
if (!this.isValidName(name)) {
|
|
2538
|
+
if (!/^[a-zA-Z_$]/g.test(name)) return `${options.type === "enum-key" ? this.config.fixInvalidEnumKeyPrefix : this.config.fixInvalidTypeNamePrefix} ${name}`;
|
|
2539
|
+
if (name.includes(".")) return name.replace(/Exclude_keyof[A-Za-z]+/g, () => "ExcludeKeys").replace(/%22~AND~%22/g, "And").replace(/%22~OR~%22/g, "Or").replace(/(\.?%22)|\./g, "_").replace(/__+$/, "");
|
|
2540
|
+
if (name.includes("-")) return startCase(name).replace(/ /g, "");
|
|
2529
2541
|
}
|
|
2530
|
-
return name
|
|
2542
|
+
return name;
|
|
2531
2543
|
};
|
|
2532
2544
|
};
|
|
2533
2545
|
|
|
2534
2546
|
//#endregion
|
|
2535
2547
|
//#region src/util/file-system.ts
|
|
2536
2548
|
var FileSystem = class {
|
|
2537
|
-
getFileContent = (path
|
|
2538
|
-
return fs.readFileSync(path
|
|
2549
|
+
getFileContent = (path) => {
|
|
2550
|
+
return fs.readFileSync(path, { encoding: "utf8" });
|
|
2539
2551
|
};
|
|
2540
|
-
readDir = (path
|
|
2541
|
-
return fs.readdirSync(path
|
|
2552
|
+
readDir = (path) => {
|
|
2553
|
+
return fs.readdirSync(path);
|
|
2542
2554
|
};
|
|
2543
|
-
pathIsDir = (path
|
|
2544
|
-
if (!path
|
|
2555
|
+
pathIsDir = (path) => {
|
|
2556
|
+
if (!path) return false;
|
|
2545
2557
|
try {
|
|
2546
|
-
return fs.statSync(path
|
|
2558
|
+
return fs.statSync(path).isDirectory();
|
|
2547
2559
|
} catch (e) {
|
|
2548
2560
|
return false;
|
|
2549
2561
|
}
|
|
@@ -2553,36 +2565,45 @@ var FileSystem = class {
|
|
|
2553
2565
|
if (fileNameParts.length > 1) fileNameParts.pop();
|
|
2554
2566
|
return fileNameParts.join(".");
|
|
2555
2567
|
};
|
|
2556
|
-
removeDir = (path
|
|
2568
|
+
removeDir = (path) => {
|
|
2557
2569
|
try {
|
|
2558
|
-
if (typeof fs.rmSync === "function") fs.rmSync(path
|
|
2559
|
-
else fs.rmdirSync(path
|
|
2570
|
+
if (typeof fs.rmSync === "function") fs.rmSync(path, { recursive: true });
|
|
2571
|
+
else fs.rmdirSync(path, { recursive: true });
|
|
2560
2572
|
} catch (e) {
|
|
2561
2573
|
consola.debug("failed to remove dir", e);
|
|
2562
2574
|
}
|
|
2563
2575
|
};
|
|
2564
|
-
createDir = (path
|
|
2576
|
+
createDir = (path) => {
|
|
2565
2577
|
try {
|
|
2566
|
-
fs.mkdirSync(path
|
|
2578
|
+
fs.mkdirSync(path, { recursive: true });
|
|
2567
2579
|
} catch (e) {
|
|
2568
2580
|
consola.debug("failed to create dir", e);
|
|
2569
2581
|
}
|
|
2570
2582
|
};
|
|
2571
|
-
cleanDir = (path
|
|
2572
|
-
this.removeDir(path
|
|
2573
|
-
this.createDir(path
|
|
2583
|
+
cleanDir = (path) => {
|
|
2584
|
+
this.removeDir(path);
|
|
2585
|
+
this.createDir(path);
|
|
2574
2586
|
};
|
|
2575
|
-
pathIsExist = (path
|
|
2576
|
-
return !!path
|
|
2587
|
+
pathIsExist = (path) => {
|
|
2588
|
+
return !!path && fs.existsSync(path);
|
|
2577
2589
|
};
|
|
2578
2590
|
createFile = ({ path: path_, fileName, content, withPrefix }) => {
|
|
2579
|
-
const __dirname
|
|
2580
|
-
const absolutePath = path$1.resolve(__dirname
|
|
2591
|
+
const __dirname = path$1.dirname(url$1.fileURLToPath(import.meta.url));
|
|
2592
|
+
const absolutePath = path$1.resolve(__dirname, path_, `./${fileName}`);
|
|
2581
2593
|
const fileContent = `${withPrefix ? FILE_PREFIX : ""}${content}`;
|
|
2582
2594
|
return fs.writeFileSync(absolutePath, fileContent);
|
|
2583
2595
|
};
|
|
2584
2596
|
};
|
|
2585
2597
|
|
|
2598
|
+
//#endregion
|
|
2599
|
+
//#region src/util/lodash-compat.ts
|
|
2600
|
+
function createLodashCompat() {
|
|
2601
|
+
return {
|
|
2602
|
+
...esToolkit,
|
|
2603
|
+
...esToolkitCompat
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2586
2607
|
//#endregion
|
|
2587
2608
|
//#region src/code-gen-process.ts
|
|
2588
2609
|
const PATCHABLE_INSTANCES = [
|
|
@@ -2637,16 +2658,14 @@ var CodeGenProcess = class {
|
|
|
2637
2658
|
if (this.config.swaggerSchema) swagger.usageSchema = this.config.swaggerSchema;
|
|
2638
2659
|
if (this.config.originalSchema) swagger.originalSchema = this.config.originalSchema;
|
|
2639
2660
|
this.schemaComponentsMap.clear();
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
]), rawTypeData);
|
|
2646
|
-
}));
|
|
2661
|
+
for (const [componentName, component] of Object.entries(swagger.usageSchema.components || {})) for (const [typeName, rawTypeData] of Object.entries(component)) this.schemaComponentsMap.createComponent(this.schemaComponentsMap.createRef([
|
|
2662
|
+
"components",
|
|
2663
|
+
componentName,
|
|
2664
|
+
typeName
|
|
2665
|
+
]), rawTypeData);
|
|
2647
2666
|
this.schemaComponentsMap.discriminatorsFirst();
|
|
2648
2667
|
this.schemaComponentsMap.enumsFirst();
|
|
2649
|
-
const parsedSchemas = this.schemaComponentsMap.filter(
|
|
2668
|
+
const parsedSchemas = this.schemaComponentsMap.filter(compact(["schemas", this.config.extractResponses && "responses"])).map((schemaComponent) => {
|
|
2650
2669
|
const parsed = this.schemaParserFabric.parseSchema(schemaComponent.rawTypeData, schemaComponent.typeName);
|
|
2651
2670
|
schemaComponent.typeData = parsed;
|
|
2652
2671
|
return parsed;
|
|
@@ -2704,7 +2723,8 @@ var CodeGenProcess = class {
|
|
|
2704
2723
|
utils: {
|
|
2705
2724
|
Ts: this.config.Ts,
|
|
2706
2725
|
formatDescription: this.schemaParserFabric.schemaFormatters.formatDescription,
|
|
2707
|
-
|
|
2726
|
+
escapeJSDocContent: this.schemaParserFabric.schemaFormatters.escapeJSDocContent,
|
|
2727
|
+
internalCase: camelCase,
|
|
2708
2728
|
classNameCase: pascalCase,
|
|
2709
2729
|
pascalCase,
|
|
2710
2730
|
getInlineParseContent: this.schemaParserFabric.getInlineParseContent,
|
|
@@ -2721,7 +2741,7 @@ var CodeGenProcess = class {
|
|
|
2721
2741
|
return ` * ${line}${eol ? "\n" : ""}`;
|
|
2722
2742
|
},
|
|
2723
2743
|
NameResolver,
|
|
2724
|
-
_:
|
|
2744
|
+
_: createLodashCompat(),
|
|
2725
2745
|
require: this.templatesWorker.requireFnFromTemplate
|
|
2726
2746
|
},
|
|
2727
2747
|
config: this.config
|
|
@@ -2730,7 +2750,7 @@ var CodeGenProcess = class {
|
|
|
2730
2750
|
collectModelTypes = () => {
|
|
2731
2751
|
const components = this.schemaComponentsMap.getComponents();
|
|
2732
2752
|
let modelTypes = [];
|
|
2733
|
-
const modelTypeComponents =
|
|
2753
|
+
const modelTypeComponents = compact(["schemas", this.config.extractResponses && "responses"]);
|
|
2734
2754
|
const getSchemaComponentsCount = () => this.schemaComponentsMap.filter(...modelTypeComponents).length;
|
|
2735
2755
|
let schemaComponentsCount = getSchemaComponentsCount();
|
|
2736
2756
|
let processedCount = 0;
|
|
@@ -2752,14 +2772,14 @@ var CodeGenProcess = class {
|
|
|
2752
2772
|
if (!typeInfo.typeData) typeInfo.typeData = this.schemaParserFabric.parseSchema(typeInfo.rawTypeData, typeInfo.typeName);
|
|
2753
2773
|
const rawTypeData = typeInfo.typeData;
|
|
2754
2774
|
const typeData = this.schemaParserFabric.schemaFormatters.base[rawTypeData.type] ? this.schemaParserFabric.schemaFormatters.base[rawTypeData.type](rawTypeData) : rawTypeData;
|
|
2755
|
-
const { typeIdentifier, name: originalName, content, description
|
|
2756
|
-
const name
|
|
2757
|
-
if (name
|
|
2775
|
+
const { typeIdentifier, name: originalName, content, description } = typeData;
|
|
2776
|
+
const name = this.typeNameFormatter.format(originalName);
|
|
2777
|
+
if (name === null) return null;
|
|
2758
2778
|
const preparedModelType = {
|
|
2759
2779
|
...typeData,
|
|
2760
2780
|
typeIdentifier,
|
|
2761
|
-
name
|
|
2762
|
-
description
|
|
2781
|
+
name,
|
|
2782
|
+
description,
|
|
2763
2783
|
$content: rawTypeData.content,
|
|
2764
2784
|
rawContent: rawTypeData.content,
|
|
2765
2785
|
content,
|
|
@@ -2771,7 +2791,7 @@ var CodeGenProcess = class {
|
|
|
2771
2791
|
generateOutputFiles = async ({ configuration }) => {
|
|
2772
2792
|
const { modular, templatesToRender } = this.config;
|
|
2773
2793
|
const output = modular ? await this.createMultipleFileInfos(templatesToRender, configuration) : await this.createSingleFileInfo(templatesToRender, configuration);
|
|
2774
|
-
if (
|
|
2794
|
+
if (configuration.extraTemplates?.length) for (const extraTemplate of configuration.extraTemplates) {
|
|
2775
2795
|
const content = this.templatesWorker.renderTemplate(this.fileSystem.getFileContent(extraTemplate.path), configuration);
|
|
2776
2796
|
output.push(...await this.createOutputFileInfo(configuration, extraTemplate.name, content));
|
|
2777
2797
|
}
|
|
@@ -2821,7 +2841,7 @@ var CodeGenProcess = class {
|
|
|
2821
2841
|
};
|
|
2822
2842
|
createSingleFileInfo = async (templatesToRender, configuration) => {
|
|
2823
2843
|
const { generateRouteTypes, generateClient } = configuration.config;
|
|
2824
|
-
return await this.createOutputFileInfo(configuration, configuration.fileName,
|
|
2844
|
+
return await this.createOutputFileInfo(configuration, configuration.fileName, compact([
|
|
2825
2845
|
this.templatesWorker.renderTemplate(templatesToRender.dataContracts, configuration),
|
|
2826
2846
|
generateRouteTypes && this.templatesWorker.renderTemplate(templatesToRender.routeTypes, configuration),
|
|
2827
2847
|
generateClient && this.templatesWorker.renderTemplate(templatesToRender.httpClient, configuration),
|
|
@@ -2857,21 +2877,21 @@ var CodeGenProcess = class {
|
|
|
2857
2877
|
createApiConfig = (swaggerSchema) => {
|
|
2858
2878
|
const { info, servers, host, basePath, externalDocs, tags } = swaggerSchema;
|
|
2859
2879
|
const server = servers?.[0] || { url: "" };
|
|
2860
|
-
const { title = "No title", version
|
|
2880
|
+
const { title = "No title", version } = info || {};
|
|
2861
2881
|
const { url: serverUrl } = server;
|
|
2862
2882
|
return {
|
|
2863
2883
|
info: info || {},
|
|
2864
2884
|
servers: servers || [],
|
|
2865
2885
|
basePath,
|
|
2866
2886
|
host,
|
|
2867
|
-
externalDocs:
|
|
2887
|
+
externalDocs: merge({
|
|
2868
2888
|
url: "",
|
|
2869
2889
|
description: ""
|
|
2870
|
-
}, externalDocs),
|
|
2871
|
-
tags:
|
|
2890
|
+
}, externalDocs || {}),
|
|
2891
|
+
tags: compact(tags || []),
|
|
2872
2892
|
baseUrl: serverUrl,
|
|
2873
2893
|
title,
|
|
2874
|
-
version
|
|
2894
|
+
version
|
|
2875
2895
|
};
|
|
2876
2896
|
};
|
|
2877
2897
|
injectClassInstance = (key, value) => {
|
|
@@ -2882,28 +2902,28 @@ var CodeGenProcess = class {
|
|
|
2882
2902
|
|
|
2883
2903
|
//#endregion
|
|
2884
2904
|
//#region types/index.ts
|
|
2885
|
-
let RequestContentKind = /* @__PURE__ */ function(RequestContentKind
|
|
2886
|
-
RequestContentKind
|
|
2887
|
-
RequestContentKind
|
|
2888
|
-
RequestContentKind
|
|
2889
|
-
RequestContentKind
|
|
2890
|
-
RequestContentKind
|
|
2891
|
-
RequestContentKind
|
|
2892
|
-
return RequestContentKind
|
|
2905
|
+
let RequestContentKind = /* @__PURE__ */ function(RequestContentKind) {
|
|
2906
|
+
RequestContentKind["JSON"] = "JSON";
|
|
2907
|
+
RequestContentKind["URL_ENCODED"] = "URL_ENCODED";
|
|
2908
|
+
RequestContentKind["FORM_DATA"] = "FORM_DATA";
|
|
2909
|
+
RequestContentKind["IMAGE"] = "IMAGE";
|
|
2910
|
+
RequestContentKind["OTHER"] = "OTHER";
|
|
2911
|
+
RequestContentKind["TEXT"] = "TEXT";
|
|
2912
|
+
return RequestContentKind;
|
|
2893
2913
|
}({});
|
|
2894
|
-
let SCHEMA_TYPES = /* @__PURE__ */ function(SCHEMA_TYPES
|
|
2895
|
-
SCHEMA_TYPES
|
|
2896
|
-
SCHEMA_TYPES
|
|
2897
|
-
SCHEMA_TYPES
|
|
2898
|
-
SCHEMA_TYPES
|
|
2899
|
-
SCHEMA_TYPES
|
|
2900
|
-
SCHEMA_TYPES
|
|
2901
|
-
SCHEMA_TYPES
|
|
2902
|
-
SCHEMA_TYPES
|
|
2903
|
-
SCHEMA_TYPES
|
|
2904
|
-
SCHEMA_TYPES
|
|
2905
|
-
SCHEMA_TYPES
|
|
2906
|
-
return SCHEMA_TYPES
|
|
2914
|
+
let SCHEMA_TYPES = /* @__PURE__ */ function(SCHEMA_TYPES) {
|
|
2915
|
+
SCHEMA_TYPES["ARRAY"] = "array";
|
|
2916
|
+
SCHEMA_TYPES["OBJECT"] = "object";
|
|
2917
|
+
SCHEMA_TYPES["ENUM"] = "enum";
|
|
2918
|
+
SCHEMA_TYPES["REF"] = "$ref";
|
|
2919
|
+
SCHEMA_TYPES["PRIMITIVE"] = "primitive";
|
|
2920
|
+
SCHEMA_TYPES["COMPLEX"] = "complex";
|
|
2921
|
+
SCHEMA_TYPES["COMPLEX_ONE_OF"] = "oneOf";
|
|
2922
|
+
SCHEMA_TYPES["COMPLEX_ANY_OF"] = "anyOf";
|
|
2923
|
+
SCHEMA_TYPES["COMPLEX_ALL_OF"] = "allOf";
|
|
2924
|
+
SCHEMA_TYPES["COMPLEX_NOT"] = "not";
|
|
2925
|
+
SCHEMA_TYPES["COMPLEX_UNKNOWN"] = "__unknown";
|
|
2926
|
+
return SCHEMA_TYPES;
|
|
2907
2927
|
}({});
|
|
2908
2928
|
|
|
2909
2929
|
//#endregion
|
|
@@ -3036,13 +3056,5 @@ async function generateTemplates(config) {
|
|
|
3036
3056
|
}
|
|
3037
3057
|
|
|
3038
3058
|
//#endregion
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
if (config.debug) consola.level = Number.MAX_SAFE_INTEGER;
|
|
3042
|
-
if (config.silent) consola.level = 0;
|
|
3043
|
-
return await new CodeGenProcess(config).start();
|
|
3044
|
-
}
|
|
3045
|
-
|
|
3046
|
-
//#endregion
|
|
3047
|
-
export { SCHEMA_TYPES as a, constants_exports as c, version as d, RequestContentKind as i, description as l, generateTemplates as n, CodeGenConfig as o, TemplatesGenConfig as r, HTTP_CLIENT as s, generateApi as t, name as u };
|
|
3048
|
-
//# sourceMappingURL=src-D-LZ3PGk.js.map
|
|
3059
|
+
export { CodeGenProcess as a, constants_exports as c, version as d, SCHEMA_TYPES as i, description as l, TemplatesGenConfig as n, CodeGenConfig as o, RequestContentKind as r, HTTP_CLIENT as s, generateTemplates as t, name as u };
|
|
3060
|
+
//# sourceMappingURL=generate-templates-DGQlyLhe.mjs.map
|