swagger-typescript-api 13.0.7 → 13.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cli/constants.js +1 -5
- package/cli/execute.js +5 -7
- package/cli/index.d.ts +7 -6
- package/cli/index.js +7 -9
- package/cli/operations/display-help.js +3 -5
- package/cli/operations/display-version.js +1 -1
- package/cli/parse-args.js +1 -3
- package/cli/process-option.js +2 -4
- package/index.js +11 -16
- package/package.json +12 -6
- package/src/code-formatter.js +5 -7
- package/src/code-gen-process.js +20 -22
- package/src/commands/generate-templates/configuration.js +3 -5
- package/src/commands/generate-templates/index.js +6 -12
- package/src/commands/generate-templates/templates-gen-process.js +8 -7
- package/src/component-type-name-resolver.js +3 -5
- package/src/configuration.js +8 -11
- package/src/constants.js +48 -36
- package/src/index.js +12 -22
- package/src/schema-components-map.js +2 -4
- package/src/schema-parser/base-schema-parsers/array.js +4 -6
- package/src/schema-parser/base-schema-parsers/complex.js +4 -6
- package/src/schema-parser/base-schema-parsers/discriminator.js +4 -6
- package/src/schema-parser/base-schema-parsers/enum.js +6 -8
- package/src/schema-parser/base-schema-parsers/object.js +4 -6
- package/src/schema-parser/base-schema-parsers/primitive.js +4 -6
- package/src/schema-parser/complex-schema-parsers/all-of.js +3 -3
- package/src/schema-parser/complex-schema-parsers/any-of.js +3 -3
- package/src/schema-parser/complex-schema-parsers/not.js +2 -2
- package/src/schema-parser/complex-schema-parsers/one-of.js +3 -3
- package/src/schema-parser/mono-schema-parser.js +1 -3
- package/src/schema-parser/schema-formatters.js +4 -6
- package/src/schema-parser/schema-parser-fabric.js +5 -7
- package/src/schema-parser/schema-parser.js +17 -25
- package/src/schema-parser/schema-utils.js +9 -14
- package/src/schema-parser/util/enum-key-resolver.js +2 -4
- package/src/schema-routes/schema-routes.js +13 -27
- package/src/schema-routes/util/specific-arg-name-resolver.js +2 -4
- package/src/schema-walker.js +2 -4
- package/src/swagger-schema-resolver.js +5 -7
- package/src/templates-worker.js +7 -7
- package/src/translators/javascript.js +3 -5
- package/src/translators/translator.js +1 -3
- package/src/type-name-formatter.js +2 -4
- package/src/util/file-system.js +8 -8
- package/src/util/id.js +2 -4
- package/src/util/internal-case.js +6 -4
- package/src/util/logger.js +3 -5
- package/src/util/name-resolver.js +2 -4
- package/src/util/object-assign.js +2 -4
- package/src/util/pascal-case.js +6 -4
- package/src/util/random.js +1 -4
- package/src/util/request.js +2 -4
- package/src/util/sort-by-property.js +1 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SCHEMA_TYPES } from "../../constants.js";
|
|
3
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
4
|
+
import { EnumKeyResolver } from "../util/enum-key-resolver.js";
|
|
5
5
|
|
|
6
6
|
class EnumSchemaParser extends MonoSchemaParser {
|
|
7
7
|
/** @type {EnumKeyResolver} */
|
|
@@ -38,7 +38,7 @@ class EnumSchemaParser extends MonoSchemaParser {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const refType = this.schemaUtils.getSchemaRefType(this.schema);
|
|
41
|
-
const $ref =
|
|
41
|
+
const $ref = refType?.$ref || null;
|
|
42
42
|
|
|
43
43
|
// fix schema when enum has length 1+ but value is []
|
|
44
44
|
if (Array.isArray(this.schema.enum)) {
|
|
@@ -153,6 +153,4 @@ class EnumSchemaParser extends MonoSchemaParser {
|
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
EnumSchemaParser,
|
|
158
|
-
};
|
|
156
|
+
export { EnumSchemaParser };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SCHEMA_TYPES } from "../../constants.js";
|
|
3
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
4
4
|
|
|
5
5
|
class ObjectSchemaParser extends MonoSchemaParser {
|
|
6
6
|
parse() {
|
|
@@ -100,6 +100,4 @@ class ObjectSchemaParser extends MonoSchemaParser {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
ObjectSchemaParser,
|
|
105
|
-
};
|
|
103
|
+
export { ObjectSchemaParser };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SCHEMA_TYPES } from "../../constants.js";
|
|
3
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
4
4
|
|
|
5
5
|
class PrimitiveSchemaParser extends MonoSchemaParser {
|
|
6
6
|
parse() {
|
|
@@ -58,6 +58,4 @@ class PrimitiveSchemaParser extends MonoSchemaParser {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
PrimitiveSchemaParser,
|
|
63
|
-
};
|
|
61
|
+
export { PrimitiveSchemaParser };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
3
3
|
|
|
4
4
|
// T1 & T2
|
|
5
5
|
class AllOfSchemaParser extends MonoSchemaParser {
|
|
@@ -23,4 +23,4 @@ class AllOfSchemaParser extends MonoSchemaParser {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
export { AllOfSchemaParser };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
3
3
|
|
|
4
4
|
// T1 | T2
|
|
5
5
|
class AnyOfSchemaParser extends MonoSchemaParser {
|
|
@@ -24,4 +24,4 @@ class AnyOfSchemaParser extends MonoSchemaParser {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
export { AnyOfSchemaParser };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
2
2
|
|
|
3
3
|
class NotSchemaParser extends MonoSchemaParser {
|
|
4
4
|
parse() {
|
|
@@ -6,4 +6,4 @@ class NotSchemaParser extends MonoSchemaParser {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export { NotSchemaParser };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { MonoSchemaParser } from "../mono-schema-parser.js";
|
|
3
3
|
|
|
4
4
|
// T1 | T2
|
|
5
5
|
class OneOfSchemaParser extends MonoSchemaParser {
|
|
@@ -24,4 +24,4 @@ class OneOfSchemaParser extends MonoSchemaParser {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
export { OneOfSchemaParser };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SCHEMA_TYPES } from "../constants.js";
|
|
3
3
|
|
|
4
4
|
class SchemaFormatters {
|
|
5
5
|
/** @type {CodeGenConfig} */
|
|
@@ -105,7 +105,7 @@ class SchemaFormatters {
|
|
|
105
105
|
_.get(parsedSchema, ["schemaType"]) ||
|
|
106
106
|
_.get(parsedSchema, ["$parsed", "schemaType"]);
|
|
107
107
|
const formatterFn = _.get(this, [formatType, schemaType]);
|
|
108
|
-
return
|
|
108
|
+
return formatterFn?.(parsedSchema) || parsedSchema;
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
formatDescription = (description, inline) => {
|
|
@@ -161,6 +161,4 @@ class SchemaFormatters {
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
SchemaFormatters,
|
|
166
|
-
};
|
|
164
|
+
export { SchemaFormatters };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SchemaFormatters } from "./schema-formatters.js";
|
|
3
|
+
import { SchemaParser } from "./schema-parser.js";
|
|
4
|
+
import { SchemaUtils } from "./schema-utils.js";
|
|
5
5
|
|
|
6
6
|
class SchemaParserFabric {
|
|
7
7
|
/** @type {CodeGenConfig} */
|
|
@@ -127,6 +127,4 @@ class SchemaParserFabric {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
SchemaParserFabric,
|
|
132
|
-
};
|
|
130
|
+
export { SchemaParserFabric };
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const { NotSchemaParser } = require("./complex-schema-parsers/not");
|
|
17
|
-
const { ArraySchemaParser } = require("./base-schema-parsers/array");
|
|
18
|
-
const { sortByProperty } = require("../util/sort-by-property");
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SCHEMA_TYPES } from "../constants.js";
|
|
3
|
+
import { sortByProperty } from "../util/sort-by-property.js";
|
|
4
|
+
import { ArraySchemaParser } from "./base-schema-parsers/array.js";
|
|
5
|
+
import { ComplexSchemaParser } from "./base-schema-parsers/complex.js";
|
|
6
|
+
import { DiscriminatorSchemaParser } from "./base-schema-parsers/discriminator.js";
|
|
7
|
+
import { EnumSchemaParser } from "./base-schema-parsers/enum.js";
|
|
8
|
+
import { ObjectSchemaParser } from "./base-schema-parsers/object.js";
|
|
9
|
+
import { PrimitiveSchemaParser } from "./base-schema-parsers/primitive.js";
|
|
10
|
+
import { AllOfSchemaParser } from "./complex-schema-parsers/all-of.js";
|
|
11
|
+
import { AnyOfSchemaParser } from "./complex-schema-parsers/any-of.js";
|
|
12
|
+
import { NotSchemaParser } from "./complex-schema-parsers/not.js";
|
|
13
|
+
import { OneOfSchemaParser } from "./complex-schema-parsers/one-of.js";
|
|
14
|
+
import { SchemaFormatters } from "./schema-formatters.js";
|
|
15
|
+
import { SchemaUtils } from "./schema-utils.js";
|
|
19
16
|
|
|
20
17
|
class SchemaParser {
|
|
21
18
|
/** @type {SchemaParserFabric} */
|
|
@@ -213,10 +210,7 @@ class SchemaParser {
|
|
|
213
210
|
this.schema = { type: this.config.Ts.Keyword.Null };
|
|
214
211
|
}
|
|
215
212
|
// schema is response schema
|
|
216
|
-
if (
|
|
217
|
-
"content" in this.schema &&
|
|
218
|
-
typeof this.schema["content"] === "object"
|
|
219
|
-
) {
|
|
213
|
+
if ("content" in this.schema && typeof this.schema.content === "object") {
|
|
220
214
|
const schema = this.extractSchemaFromResponseStruct(this.schema);
|
|
221
215
|
const schemaParser = this.schemaParserFabric.createSchemaParser({
|
|
222
216
|
schema,
|
|
@@ -298,6 +292,4 @@ class SchemaParser {
|
|
|
298
292
|
};
|
|
299
293
|
}
|
|
300
294
|
|
|
301
|
-
|
|
302
|
-
SchemaParser,
|
|
303
|
-
};
|
|
295
|
+
export { SchemaParser };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { camelCase } = require("lodash");
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { SCHEMA_TYPES } from "../constants.js";
|
|
3
|
+
import { internalCase } from "../util/internal-case.js";
|
|
4
|
+
import { pascalCase } from "../util/pascal-case.js";
|
|
6
5
|
|
|
7
6
|
class SchemaUtils {
|
|
8
7
|
/** @type {CodeGenConfig} */
|
|
@@ -33,13 +32,13 @@ class SchemaUtils {
|
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
isRefSchema = (schema) => {
|
|
36
|
-
return !!
|
|
35
|
+
return !!schema?.$ref;
|
|
37
36
|
};
|
|
38
37
|
|
|
39
38
|
getEnumNames = (schema) => {
|
|
40
39
|
return (
|
|
41
40
|
schema["x-enumNames"] ||
|
|
42
|
-
schema
|
|
41
|
+
schema.xEnumNames ||
|
|
43
42
|
schema["x-enumnames"] ||
|
|
44
43
|
schema["x-enum-varnames"]
|
|
45
44
|
);
|
|
@@ -143,9 +142,7 @@ class SchemaUtils {
|
|
|
143
142
|
const refData = this.getSchemaRefType(childSchema);
|
|
144
143
|
|
|
145
144
|
if (refData) {
|
|
146
|
-
const refObjectProperties = _.keys(
|
|
147
|
-
(refData.rawTypeData && refData.rawTypeData.properties) || {},
|
|
148
|
-
);
|
|
145
|
+
const refObjectProperties = _.keys(refData.rawTypeData?.properties || {});
|
|
149
146
|
const existedRequiredKeys = refObjectProperties.filter((key) =>
|
|
150
147
|
required.includes(key),
|
|
151
148
|
);
|
|
@@ -287,7 +284,7 @@ class SchemaUtils {
|
|
|
287
284
|
if (!schemaPath || !schemaPath[0]) return null;
|
|
288
285
|
|
|
289
286
|
return pascalCase(
|
|
290
|
-
camelCase(
|
|
287
|
+
_.camelCase(
|
|
291
288
|
_.uniq([schemaPath[0], schemaPath[schemaPath.length - 1]]).join("_"),
|
|
292
289
|
),
|
|
293
290
|
);
|
|
@@ -319,6 +316,4 @@ class SchemaUtils {
|
|
|
319
316
|
};
|
|
320
317
|
}
|
|
321
318
|
|
|
322
|
-
|
|
323
|
-
SchemaUtils,
|
|
324
|
-
};
|
|
319
|
+
export { SchemaUtils };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { NameResolver } from "../../util/name-resolver.js";
|
|
2
2
|
|
|
3
3
|
class EnumKeyResolver extends NameResolver {
|
|
4
4
|
counter = 1;
|
|
@@ -21,6 +21,4 @@ class EnumKeyResolver extends NameResolver {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
EnumKeyResolver,
|
|
26
|
-
};
|
|
24
|
+
export { EnumKeyResolver };
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
SpecificArgNameResolver,
|
|
5
|
-
} = require("./util/specific-arg-name-resolver");
|
|
6
|
-
const {
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import {
|
|
7
3
|
DEFAULT_BODY_ARG_NAME,
|
|
8
4
|
RESERVED_BODY_ARG_NAMES,
|
|
9
5
|
RESERVED_HEADER_ARG_NAMES,
|
|
10
6
|
RESERVED_PATH_ARG_NAMES,
|
|
11
7
|
RESERVED_QUERY_ARG_NAMES,
|
|
12
|
-
}
|
|
13
|
-
|
|
8
|
+
} from "../constants.js";
|
|
9
|
+
import { generateId } from "../util/id.js";
|
|
10
|
+
import { SpecificArgNameResolver } from "./util/specific-arg-name-resolver.js";
|
|
14
11
|
|
|
15
12
|
const CONTENT_KIND = {
|
|
16
13
|
JSON: "JSON",
|
|
@@ -160,7 +157,7 @@ class SchemaRoutes {
|
|
|
160
157
|
const queryParamMatches = fixedRoute.match(/(\{\?.*\})/g);
|
|
161
158
|
const queryParams = [];
|
|
162
159
|
|
|
163
|
-
if (queryParamMatches
|
|
160
|
+
if (queryParamMatches?.length) {
|
|
164
161
|
queryParamMatches.forEach((match) => {
|
|
165
162
|
fixedRoute = fixedRoute.replace(match, "");
|
|
166
163
|
});
|
|
@@ -220,11 +217,7 @@ class SchemaRoutes {
|
|
|
220
217
|
this.schemaParserFabric.schemaUtils.getSchemaRefType(parameter);
|
|
221
218
|
let routeParam = null;
|
|
222
219
|
|
|
223
|
-
if (
|
|
224
|
-
refTypeInfo &&
|
|
225
|
-
refTypeInfo.rawTypeData.in &&
|
|
226
|
-
refTypeInfo.rawTypeData
|
|
227
|
-
) {
|
|
220
|
+
if (refTypeInfo?.rawTypeData.in && refTypeInfo.rawTypeData) {
|
|
228
221
|
if (!routeParams[refTypeInfo.rawTypeData.in]) {
|
|
229
222
|
routeParams[refTypeInfo.rawTypeData.in] = [];
|
|
230
223
|
}
|
|
@@ -345,7 +338,7 @@ class SchemaRoutes {
|
|
|
345
338
|
|
|
346
339
|
/* for example: dataType = "multipart/form-data" */
|
|
347
340
|
for (const dataType in content) {
|
|
348
|
-
if (content[dataType]
|
|
341
|
+
if (content[dataType]?.schema) {
|
|
349
342
|
return {
|
|
350
343
|
...content[dataType].schema,
|
|
351
344
|
dataType,
|
|
@@ -510,9 +503,7 @@ class SchemaRoutes {
|
|
|
510
503
|
responses: responseInfos,
|
|
511
504
|
success: {
|
|
512
505
|
schema: successResponse,
|
|
513
|
-
type:
|
|
514
|
-
(successResponse && successResponse.type) ||
|
|
515
|
-
this.config.Ts.Keyword.Any,
|
|
506
|
+
type: successResponse?.type || this.config.Ts.Keyword.Any,
|
|
516
507
|
},
|
|
517
508
|
error: {
|
|
518
509
|
schemas: errorResponses,
|
|
@@ -546,7 +537,7 @@ class SchemaRoutes {
|
|
|
546
537
|
let usageName = `${schemaPart.name}`;
|
|
547
538
|
|
|
548
539
|
if (usageName.includes(".")) {
|
|
549
|
-
usageName = camelCase(usageName);
|
|
540
|
+
usageName = _.camelCase(usageName);
|
|
550
541
|
}
|
|
551
542
|
|
|
552
543
|
return {
|
|
@@ -640,10 +631,7 @@ class SchemaRoutes {
|
|
|
640
631
|
}
|
|
641
632
|
|
|
642
633
|
return {
|
|
643
|
-
paramName:
|
|
644
|
-
requestBodyName ||
|
|
645
|
-
(requestBody && requestBody.name) ||
|
|
646
|
-
DEFAULT_BODY_ARG_NAME,
|
|
634
|
+
paramName: requestBodyName || requestBody?.name || DEFAULT_BODY_ARG_NAME,
|
|
647
635
|
contentTypes,
|
|
648
636
|
contentKind,
|
|
649
637
|
schema,
|
|
@@ -892,7 +880,7 @@ class SchemaRoutes {
|
|
|
892
880
|
moduleNameFirstTag && firstTag
|
|
893
881
|
? _.camelCase(firstTag)
|
|
894
882
|
: _.camelCase(_.compact(_.split(route, "/"))[moduleNameIndex]);
|
|
895
|
-
let hasSecurity = !!
|
|
883
|
+
let hasSecurity = !!globalSecurity?.length;
|
|
896
884
|
if (security) {
|
|
897
885
|
hasSecurity = security.length > 0;
|
|
898
886
|
}
|
|
@@ -1217,6 +1205,4 @@ class SchemaRoutes {
|
|
|
1217
1205
|
};
|
|
1218
1206
|
}
|
|
1219
1207
|
|
|
1220
|
-
|
|
1221
|
-
SchemaRoutes,
|
|
1222
|
-
};
|
|
1208
|
+
export { SchemaRoutes };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { NameResolver } from "../../util/name-resolver.js";
|
|
2
2
|
|
|
3
3
|
class SpecificArgNameResolver extends NameResolver {
|
|
4
4
|
counter = 1;
|
|
@@ -21,6 +21,4 @@ class SpecificArgNameResolver extends NameResolver {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
SpecificArgNameResolver,
|
|
26
|
-
};
|
|
24
|
+
export { SpecificArgNameResolver };
|
package/src/schema-walker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
2
|
|
|
3
3
|
// TODO: WIP
|
|
4
4
|
// this class will be needed to walk by schema everywhere
|
|
@@ -88,6 +88,4 @@ class SchemaWalker {
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
SchemaWalker,
|
|
93
|
-
};
|
|
91
|
+
export { SchemaWalker };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import yaml from "js-yaml";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
import converter from "swagger2openapi";
|
|
4
|
+
import { Request } from "./util/request.js";
|
|
5
5
|
|
|
6
6
|
class SwaggerSchemaResolver {
|
|
7
7
|
/**
|
|
@@ -192,6 +192,4 @@ class SwaggerSchemaResolver {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
|
|
196
|
-
SwaggerSchemaResolver,
|
|
197
|
-
};
|
|
195
|
+
export { SwaggerSchemaResolver };
|
package/src/templates-worker.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import url from "node:url";
|
|
4
|
+
import * as Eta from "eta";
|
|
5
|
+
import _ from "lodash";
|
|
5
6
|
|
|
6
7
|
class TemplatesWorker {
|
|
7
8
|
/**
|
|
@@ -34,6 +35,7 @@ class TemplatesWorker {
|
|
|
34
35
|
* @returns {CodeGenConfig.templatePaths}
|
|
35
36
|
*/
|
|
36
37
|
getTemplatePaths = (config) => {
|
|
38
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
37
39
|
const baseTemplatesPath = resolve(__dirname, "../templates/base");
|
|
38
40
|
const defaultTemplatesPath = resolve(__dirname, "../templates/default");
|
|
39
41
|
const modularTemplatesPath = resolve(__dirname, "../templates/modular");
|
|
@@ -238,6 +240,4 @@ class TemplatesWorker {
|
|
|
238
240
|
};
|
|
239
241
|
}
|
|
240
242
|
|
|
241
|
-
|
|
242
|
-
TemplatesWorker,
|
|
243
|
-
};
|
|
243
|
+
export { TemplatesWorker };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { Translator } from "./translator.js";
|
|
3
3
|
|
|
4
4
|
class JavascriptTranslator extends Translator {
|
|
5
5
|
/**
|
|
@@ -78,6 +78,4 @@ class JavascriptTranslator extends Translator {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
JavascriptTranslator,
|
|
83
|
-
};
|
|
81
|
+
export { JavascriptTranslator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {"enum-key" | "type-name"} FormattingSchemaType
|
|
@@ -108,6 +108,4 @@ class TypeNameFormatter {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
TypeNameFormatter,
|
|
113
|
-
};
|
|
111
|
+
export { TypeNameFormatter };
|
package/src/util/file-system.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import url from "node:url";
|
|
4
|
+
import _ from "lodash";
|
|
5
|
+
import { Logger } from "./logger.js";
|
|
5
6
|
|
|
6
7
|
const FILE_PREFIX = `/* eslint-disable */
|
|
7
8
|
/* tslint:disable */
|
|
@@ -25,7 +26,7 @@ class FileSystem {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
getFileContent = (path) => {
|
|
28
|
-
return fs.readFileSync(path, { encoding: "
|
|
29
|
+
return fs.readFileSync(path, { encoding: "utf8" });
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
readDir = (path) => {
|
|
@@ -83,6 +84,7 @@ class FileSystem {
|
|
|
83
84
|
};
|
|
84
85
|
|
|
85
86
|
createFile = ({ path, fileName, content, withPrefix }) => {
|
|
87
|
+
const __dirname = dirname(url.fileURLToPath(import.meta.url));
|
|
86
88
|
const absolutePath = resolve(__dirname, path, `./${fileName}`);
|
|
87
89
|
const fileContent = `${withPrefix ? FILE_PREFIX : ""}${content}`;
|
|
88
90
|
|
|
@@ -90,6 +92,4 @@ class FileSystem {
|
|
|
90
92
|
};
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
|
|
94
|
-
FileSystem,
|
|
95
|
-
};
|
|
95
|
+
export { FileSystem };
|
package/src/util/id.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { customAlphabet } from "nanoid";
|
|
2
2
|
|
|
3
3
|
const ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
4
4
|
|
|
5
5
|
const generateId = customAlphabet(ALPHABET, 12);
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
generateId,
|
|
9
|
-
};
|
|
7
|
+
export { generateId };
|
package/src/util/logger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import { emojify } from "node-emoji";
|
|
3
3
|
|
|
4
4
|
class Logger {
|
|
5
5
|
firstLog = true;
|
|
@@ -139,6 +139,4 @@ class Logger {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
Logger,
|
|
144
|
-
};
|
|
142
|
+
export { Logger };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import _ from "lodash";
|
|
2
2
|
|
|
3
3
|
const objectAssign = (target, updaterFn) => {
|
|
4
4
|
if (!updaterFn) return;
|
|
@@ -14,6 +14,4 @@ const objectAssign = (target, updaterFn) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
objectAssign,
|
|
19
|
-
};
|
|
17
|
+
export { objectAssign };
|
package/src/util/pascal-case.js
CHANGED