swagger-typescript-api 13.2.9 → 13.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.d.cts +1 -2
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +1 -1
- package/dist/lib.cjs +3 -1
- package/dist/lib.d.cts +27 -1
- package/dist/lib.d.ts +27 -1
- package/dist/lib.js +2 -2
- package/dist/{src-B-cU8h_Y.cjs → src-C5bMYV9w.cjs} +100 -62
- package/dist/src-C5bMYV9w.cjs.map +1 -0
- package/dist/{src-BGOGeWR6.js → src-s8addnrG.js} +89 -63
- package/dist/src-s8addnrG.js.map +1 -0
- package/package.json +9 -9
- package/dist/src-B-cU8h_Y.cjs.map +0 -1
- package/dist/src-BGOGeWR6.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# swagger-typescript-api
|
|
2
2
|
|
|
3
|
+
## 13.2.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7b7351f`](https://github.com/acacode/swagger-typescript-api/commit/7b7351f90b250f7702cb57976c5c293ede353312) Thanks [@js2me](https://github.com/js2me)! - fix missing exported interfaces and types
|
|
8
|
+
|
|
3
9
|
## 13.2.9
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_src = require('./src-
|
|
2
|
+
const require_src = require('./src-C5bMYV9w.cjs');
|
|
3
3
|
const node_path = require_src.__toESM(require("node:path"));
|
|
4
4
|
const c12 = require_src.__toESM(require("c12"));
|
|
5
5
|
const citty = require_src.__toESM(require("citty"));
|
package/dist/cli.d.cts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export {};
|
|
1
|
+
export { };
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export {};
|
|
1
|
+
export { };
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-
|
|
2
|
+
import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-s8addnrG.js";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
4
|
import { loadConfig } from "c12";
|
|
5
5
|
import { defineCommand, runMain } from "citty";
|
package/dist/lib.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
const require_src = require('./src-
|
|
1
|
+
const require_src = require('./src-C5bMYV9w.cjs');
|
|
2
2
|
|
|
3
|
+
exports.RequestContentKind = require_src.RequestContentKind;
|
|
4
|
+
exports.SCHEMA_TYPES = require_src.SCHEMA_TYPES;
|
|
3
5
|
Object.defineProperty(exports, 'constants', {
|
|
4
6
|
enumerable: true,
|
|
5
7
|
get: function () {
|
package/dist/lib.d.cts
CHANGED
|
@@ -822,6 +822,25 @@ type PrimitiveTypeStructValue = string | ((schema: Record<string, unknown>, pars
|
|
|
822
822
|
type PrimitiveTypeStruct = Record<"integer" | "number" | "boolean" | "object" | "file" | "string" | "array", string | ({
|
|
823
823
|
$default: PrimitiveTypeStructValue;
|
|
824
824
|
} & Record<string, PrimitiveTypeStructValue>)>;
|
|
825
|
+
interface GenerateApiParamsFromPath extends Partial<GenerateApiConfiguration["config"]> {
|
|
826
|
+
/**
|
|
827
|
+
* path to swagger schema
|
|
828
|
+
*/
|
|
829
|
+
input: string;
|
|
830
|
+
}
|
|
831
|
+
interface GenerateApiParamsFromUrl extends Partial<GenerateApiConfiguration["config"]> {
|
|
832
|
+
/**
|
|
833
|
+
* url to swagger schema
|
|
834
|
+
*/
|
|
835
|
+
url: string;
|
|
836
|
+
}
|
|
837
|
+
interface GenerateApiParamsFromSpecLiteral extends Partial<GenerateApiConfiguration["config"]> {
|
|
838
|
+
/**
|
|
839
|
+
* swagger schema JSON
|
|
840
|
+
*/
|
|
841
|
+
spec: swagger_schema_official0.Spec;
|
|
842
|
+
}
|
|
843
|
+
type GenerateApiParams = GenerateApiParamsFromPath | GenerateApiParamsFromUrl | GenerateApiParamsFromSpecLiteral;
|
|
825
844
|
type BuildRouteParam = {
|
|
826
845
|
/** {bar} */
|
|
827
846
|
$match: string;
|
|
@@ -870,6 +889,7 @@ interface Hooks {
|
|
|
870
889
|
/** customize name of route (operationId), you can do it with using onCreateRouteName too */
|
|
871
890
|
onFormatRouteName?: (routeInfo: RawRouteInfo, templateRouteName: string) => string | undefined;
|
|
872
891
|
}
|
|
892
|
+
type RouteNameRouteInfo = Record<string, unknown>;
|
|
873
893
|
type RouteNameInfo = {
|
|
874
894
|
usage: string;
|
|
875
895
|
original: string;
|
|
@@ -912,6 +932,12 @@ interface ParsedSchema<C> {
|
|
|
912
932
|
isExtractedResponseBody?: boolean;
|
|
913
933
|
isExtractedResponseError?: boolean;
|
|
914
934
|
}
|
|
935
|
+
interface PathArgInfo {
|
|
936
|
+
name: string;
|
|
937
|
+
optional: boolean;
|
|
938
|
+
type: string;
|
|
939
|
+
description?: string;
|
|
940
|
+
}
|
|
915
941
|
interface SchemaComponent {
|
|
916
942
|
$ref: string;
|
|
917
943
|
typeName: string;
|
|
@@ -1802,5 +1828,5 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1802
1828
|
}) => Promise<string>;
|
|
1803
1829
|
}>;
|
|
1804
1830
|
//#endregion
|
|
1805
|
-
export { constants_d_exports as constants, generateApi, generateTemplates };
|
|
1831
|
+
export { ExtractingOptions, GenerateApiConfiguration, GenerateApiOutput, GenerateApiParams, GenerateTemplatesOutput, GenerateTemplatesParams, Hooks, HttpClientType, ModelType, ParsedRoute, ParsedRouteRequest, ParsedRouteResponse, ParsedSchema, PathArgInfo, RawRouteInfo, RequestContentKind, RequestResponseInfo, RouteNameInfo, RouteNameRouteInfo, SCHEMA_TYPES, SchemaComponent, SchemaTypeEnumContent, SchemaTypeObjectContent, SchemaTypePrimitiveContent, constants_d_exports as constants, generateApi, generateTemplates };
|
|
1806
1832
|
//# sourceMappingURL=lib.d.cts.map
|
package/dist/lib.d.ts
CHANGED
|
@@ -820,6 +820,25 @@ type PrimitiveTypeStructValue = string | ((schema: Record<string, unknown>, pars
|
|
|
820
820
|
type PrimitiveTypeStruct = Record<"integer" | "number" | "boolean" | "object" | "file" | "string" | "array", string | ({
|
|
821
821
|
$default: PrimitiveTypeStructValue;
|
|
822
822
|
} & Record<string, PrimitiveTypeStructValue>)>;
|
|
823
|
+
interface GenerateApiParamsFromPath extends Partial<GenerateApiConfiguration["config"]> {
|
|
824
|
+
/**
|
|
825
|
+
* path to swagger schema
|
|
826
|
+
*/
|
|
827
|
+
input: string;
|
|
828
|
+
}
|
|
829
|
+
interface GenerateApiParamsFromUrl extends Partial<GenerateApiConfiguration["config"]> {
|
|
830
|
+
/**
|
|
831
|
+
* url to swagger schema
|
|
832
|
+
*/
|
|
833
|
+
url: string;
|
|
834
|
+
}
|
|
835
|
+
interface GenerateApiParamsFromSpecLiteral extends Partial<GenerateApiConfiguration["config"]> {
|
|
836
|
+
/**
|
|
837
|
+
* swagger schema JSON
|
|
838
|
+
*/
|
|
839
|
+
spec: swagger_schema_official0.Spec;
|
|
840
|
+
}
|
|
841
|
+
type GenerateApiParams = GenerateApiParamsFromPath | GenerateApiParamsFromUrl | GenerateApiParamsFromSpecLiteral;
|
|
823
842
|
type BuildRouteParam = {
|
|
824
843
|
/** {bar} */
|
|
825
844
|
$match: string;
|
|
@@ -868,6 +887,7 @@ interface Hooks {
|
|
|
868
887
|
/** customize name of route (operationId), you can do it with using onCreateRouteName too */
|
|
869
888
|
onFormatRouteName?: (routeInfo: RawRouteInfo, templateRouteName: string) => string | undefined;
|
|
870
889
|
}
|
|
890
|
+
type RouteNameRouteInfo = Record<string, unknown>;
|
|
871
891
|
type RouteNameInfo = {
|
|
872
892
|
usage: string;
|
|
873
893
|
original: string;
|
|
@@ -910,6 +930,12 @@ interface ParsedSchema<C> {
|
|
|
910
930
|
isExtractedResponseBody?: boolean;
|
|
911
931
|
isExtractedResponseError?: boolean;
|
|
912
932
|
}
|
|
933
|
+
interface PathArgInfo {
|
|
934
|
+
name: string;
|
|
935
|
+
optional: boolean;
|
|
936
|
+
type: string;
|
|
937
|
+
description?: string;
|
|
938
|
+
}
|
|
913
939
|
interface SchemaComponent {
|
|
914
940
|
$ref: string;
|
|
915
941
|
typeName: string;
|
|
@@ -1800,5 +1826,5 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1800
1826
|
}) => Promise<string>;
|
|
1801
1827
|
}>;
|
|
1802
1828
|
//#endregion
|
|
1803
|
-
export { constants_d_exports as constants, generateApi, generateTemplates };
|
|
1829
|
+
export { ExtractingOptions, GenerateApiConfiguration, GenerateApiOutput, GenerateApiParams, GenerateTemplatesOutput, GenerateTemplatesParams, Hooks, HttpClientType, ModelType, ParsedRoute, ParsedRouteRequest, ParsedRouteResponse, ParsedSchema, PathArgInfo, RawRouteInfo, RequestContentKind, RequestResponseInfo, RouteNameInfo, RouteNameRouteInfo, SCHEMA_TYPES, SchemaComponent, SchemaTypeEnumContent, SchemaTypeObjectContent, SchemaTypePrimitiveContent, constants_d_exports as constants, generateApi, generateTemplates };
|
|
1804
1830
|
//# sourceMappingURL=lib.d.ts.map
|
package/dist/lib.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { constants_exports, generateApi, generateTemplates } from "./src-
|
|
1
|
+
import { RequestContentKind, SCHEMA_TYPES, constants_exports, generateApi, generateTemplates } from "./src-s8addnrG.js";
|
|
2
2
|
|
|
3
|
-
export { constants_exports as constants, generateApi, generateTemplates };
|
|
3
|
+
export { RequestContentKind, SCHEMA_TYPES, constants_exports as constants, generateApi, generateTemplates };
|
|
@@ -204,7 +204,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
204
204
|
//#endregion
|
|
205
205
|
//#region package.json
|
|
206
206
|
var name = "swagger-typescript-api";
|
|
207
|
-
var version = "13.2.
|
|
207
|
+
var version = "13.2.10";
|
|
208
208
|
var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
|
|
209
209
|
var homepage = "https://github.com/acacode/swagger-typescript-api";
|
|
210
210
|
var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
|
|
@@ -245,7 +245,7 @@ var scripts = {
|
|
|
245
245
|
};
|
|
246
246
|
var dependencies = {
|
|
247
247
|
"@biomejs/js-api": "3.0.0",
|
|
248
|
-
"@biomejs/wasm-nodejs": "2.2.
|
|
248
|
+
"@biomejs/wasm-nodejs": "2.2.4",
|
|
249
249
|
"@types/swagger-schema-official": "^2.0.25",
|
|
250
250
|
"c12": "^3.2.0",
|
|
251
251
|
"citty": "^0.1.6",
|
|
@@ -259,19 +259,19 @@ var dependencies = {
|
|
|
259
259
|
"typescript": "~5.9.2"
|
|
260
260
|
};
|
|
261
261
|
var devDependencies = {
|
|
262
|
-
"@biomejs/biome": "2.2.
|
|
262
|
+
"@biomejs/biome": "2.2.4",
|
|
263
263
|
"@changesets/changelog-github": "0.5.1",
|
|
264
|
-
"@changesets/cli": "2.29.
|
|
265
|
-
"@tsconfig/
|
|
264
|
+
"@changesets/cli": "2.29.7",
|
|
265
|
+
"@tsconfig/node20": "20.1.6",
|
|
266
266
|
"@tsconfig/strictest": "2.0.5",
|
|
267
267
|
"@types/js-yaml": "4.0.9",
|
|
268
268
|
"@types/lodash": "4.17.20",
|
|
269
|
-
"@types/node": "24.3.
|
|
269
|
+
"@types/node": "24.3.2",
|
|
270
270
|
"@types/swagger2openapi": "7.0.4",
|
|
271
|
-
"axios": "1.
|
|
271
|
+
"axios": "1.12.1",
|
|
272
272
|
"openapi-types": "12.1.3",
|
|
273
|
-
"tsdown": "0.
|
|
274
|
-
"typedoc": "0.28.
|
|
273
|
+
"tsdown": "0.15.1",
|
|
274
|
+
"typedoc": "0.28.12",
|
|
275
275
|
"vitest": "3.2.4"
|
|
276
276
|
};
|
|
277
277
|
var packageManager = "yarn@4.9.4";
|
|
@@ -324,7 +324,7 @@ __export(constants_exports, {
|
|
|
324
324
|
RESERVED_PATH_ARG_NAMES: () => RESERVED_PATH_ARG_NAMES,
|
|
325
325
|
RESERVED_QUERY_ARG_NAMES: () => RESERVED_QUERY_ARG_NAMES,
|
|
326
326
|
RESERVED_REQ_PARAMS_ARG_NAMES: () => RESERVED_REQ_PARAMS_ARG_NAMES,
|
|
327
|
-
SCHEMA_TYPES: () => SCHEMA_TYPES
|
|
327
|
+
SCHEMA_TYPES: () => SCHEMA_TYPES$1
|
|
328
328
|
});
|
|
329
329
|
const DEFAULT_BODY_ARG_NAME = "data";
|
|
330
330
|
const FILE_PREFIX = `/* eslint-disable */
|
|
@@ -363,7 +363,7 @@ const RESERVED_REQ_PARAMS_ARG_NAMES = [
|
|
|
363
363
|
"reqParams",
|
|
364
364
|
"httpParams"
|
|
365
365
|
];
|
|
366
|
-
const SCHEMA_TYPES = {
|
|
366
|
+
const SCHEMA_TYPES$1 = {
|
|
367
367
|
ARRAY: "array",
|
|
368
368
|
OBJECT: "object",
|
|
369
369
|
ENUM: "enum",
|
|
@@ -788,7 +788,7 @@ var SchemaFormatters = class {
|
|
|
788
788
|
this.templatesWorker = schemaParser.templatesWorker;
|
|
789
789
|
}
|
|
790
790
|
base = {
|
|
791
|
-
[SCHEMA_TYPES.ENUM]: (parsedSchema) => {
|
|
791
|
+
[SCHEMA_TYPES$1.ENUM]: (parsedSchema) => {
|
|
792
792
|
if (this.config.generateUnionEnums) return {
|
|
793
793
|
...parsedSchema,
|
|
794
794
|
$content: parsedSchema.content,
|
|
@@ -800,15 +800,15 @@ var SchemaFormatters = class {
|
|
|
800
800
|
content: this.config.Ts.EnumFieldsWrapper(parsedSchema.content)
|
|
801
801
|
};
|
|
802
802
|
},
|
|
803
|
-
[SCHEMA_TYPES.OBJECT]: (parsedSchema) => {
|
|
804
|
-
if (parsedSchema.nullable) return this.inline[SCHEMA_TYPES.OBJECT](parsedSchema);
|
|
803
|
+
[SCHEMA_TYPES$1.OBJECT]: (parsedSchema) => {
|
|
804
|
+
if (parsedSchema.nullable) return this.inline[SCHEMA_TYPES$1.OBJECT](parsedSchema);
|
|
805
805
|
return {
|
|
806
806
|
...parsedSchema,
|
|
807
807
|
$content: parsedSchema.content,
|
|
808
808
|
content: this.formatObjectContent(parsedSchema.content)
|
|
809
809
|
};
|
|
810
810
|
},
|
|
811
|
-
[SCHEMA_TYPES.PRIMITIVE]: (parsedSchema) => {
|
|
811
|
+
[SCHEMA_TYPES$1.PRIMITIVE]: (parsedSchema) => {
|
|
812
812
|
return {
|
|
813
813
|
...parsedSchema,
|
|
814
814
|
$content: parsedSchema.content
|
|
@@ -816,13 +816,13 @@ var SchemaFormatters = class {
|
|
|
816
816
|
}
|
|
817
817
|
};
|
|
818
818
|
inline = {
|
|
819
|
-
[SCHEMA_TYPES.ENUM]: (parsedSchema) => {
|
|
819
|
+
[SCHEMA_TYPES$1.ENUM]: (parsedSchema) => {
|
|
820
820
|
return {
|
|
821
821
|
...parsedSchema,
|
|
822
822
|
content: parsedSchema.$ref ? parsedSchema.typeName : this.config.Ts.UnionType(lodash.default.compact([...parsedSchema.content.map(({ value }) => `${value}`), parsedSchema.nullable && this.config.Ts.Keyword.Null])) || this.config.Ts.Keyword.Any
|
|
823
823
|
};
|
|
824
824
|
},
|
|
825
|
-
[SCHEMA_TYPES.OBJECT]: (parsedSchema) => {
|
|
825
|
+
[SCHEMA_TYPES$1.OBJECT]: (parsedSchema) => {
|
|
826
826
|
if (typeof parsedSchema.content === "string") return {
|
|
827
827
|
...parsedSchema,
|
|
828
828
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
@@ -908,7 +908,7 @@ var ArraySchemaParser = class extends MonoSchemaParser {
|
|
|
908
908
|
parse() {
|
|
909
909
|
let contentType;
|
|
910
910
|
const { type: type$1, description: description$1, items } = this.schema || {};
|
|
911
|
-
if (Array.isArray(items) && type$1 === SCHEMA_TYPES.ARRAY) {
|
|
911
|
+
if (Array.isArray(items) && type$1 === SCHEMA_TYPES$1.ARRAY) {
|
|
912
912
|
const tupleContent = [];
|
|
913
913
|
for (const item of items) tupleContent.push(this.schemaParserFabric.createSchemaParser({
|
|
914
914
|
schema: item,
|
|
@@ -926,8 +926,8 @@ var ArraySchemaParser = class extends MonoSchemaParser {
|
|
|
926
926
|
...typeof this.schema === "object" ? this.schema : {},
|
|
927
927
|
$schemaPath: this.schemaPath.slice(),
|
|
928
928
|
$parsedSchema: true,
|
|
929
|
-
schemaType: SCHEMA_TYPES.PRIMITIVE,
|
|
930
|
-
type: SCHEMA_TYPES.PRIMITIVE,
|
|
929
|
+
schemaType: SCHEMA_TYPES$1.PRIMITIVE,
|
|
930
|
+
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
931
931
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
932
932
|
name: this.typeName,
|
|
933
933
|
description: this.schemaFormatters.formatDescription(description$1),
|
|
@@ -947,12 +947,12 @@ var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
|
947
947
|
...typeof this.schema === "object" ? this.schema : {},
|
|
948
948
|
$schemaPath: this.schemaPath.slice(),
|
|
949
949
|
$parsedSchema: true,
|
|
950
|
-
schemaType: SCHEMA_TYPES.COMPLEX,
|
|
951
|
-
type: SCHEMA_TYPES.PRIMITIVE,
|
|
950
|
+
schemaType: SCHEMA_TYPES$1.COMPLEX,
|
|
951
|
+
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
952
952
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
953
953
|
name: this.typeName,
|
|
954
954
|
description: this.schemaFormatters.formatDescription(this.schema.description || lodash.default.compact(lodash.default.map(this.schema[complexType], "description"))[0] || ""),
|
|
955
|
-
content: this.config.Ts.IntersectionType(lodash.default.compact([this.config.Ts.ExpressionGroup(complexSchemaContent), this.schemaUtils.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES.OBJECT && this.config.Ts.ExpressionGroup(this.schemaParserFabric.createSchemaParser({
|
|
955
|
+
content: this.config.Ts.IntersectionType(lodash.default.compact([this.config.Ts.ExpressionGroup(complexSchemaContent), this.schemaUtils.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES$1.OBJECT && this.config.Ts.ExpressionGroup(this.schemaParserFabric.createSchemaParser({
|
|
956
956
|
schema: simpleSchema,
|
|
957
957
|
schemaPath: this.schemaPath
|
|
958
958
|
}).getInlineParseContent())])) || this.config.Ts.Keyword.Any
|
|
@@ -982,8 +982,8 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
982
982
|
...typeof this.schema === "object" ? this.schema : {},
|
|
983
983
|
$schemaPath: this.schemaPath.slice(),
|
|
984
984
|
$parsedSchema: true,
|
|
985
|
-
schemaType: SCHEMA_TYPES.COMPLEX,
|
|
986
|
-
type: SCHEMA_TYPES.PRIMITIVE,
|
|
985
|
+
schemaType: SCHEMA_TYPES$1.COMPLEX,
|
|
986
|
+
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
987
987
|
typeIdentifier: ts.Keyword.Type,
|
|
988
988
|
name: this.typeName,
|
|
989
989
|
description: this.schemaFormatters.formatDescription(this.schema.description),
|
|
@@ -1062,7 +1062,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1062
1062
|
let mappingPropertySchemaEnumKeysMap = {};
|
|
1063
1063
|
let mappingPropertySchema = lodash.default.get(abstractSchemaStruct?.component?.rawTypeData, ["properties", discPropertyName]);
|
|
1064
1064
|
if (this.schemaUtils.isRefSchema(mappingPropertySchema)) mappingPropertySchema = this.schemaUtils.getSchemaRefType(mappingPropertySchema);
|
|
1065
|
-
if (mappingPropertySchema?.rawTypeData?.$parsed?.type === SCHEMA_TYPES.ENUM) mappingPropertySchemaEnumKeysMap = lodash.default.reduce(mappingPropertySchema.rawTypeData.$parsed.enum, (acc, key, index) => {
|
|
1065
|
+
if (mappingPropertySchema?.rawTypeData?.$parsed?.type === SCHEMA_TYPES$1.ENUM) mappingPropertySchemaEnumKeysMap = lodash.default.reduce(mappingPropertySchema.rawTypeData.$parsed.enum, (acc, key, index) => {
|
|
1066
1066
|
const enumKey = mappingPropertySchema.rawTypeData.$parsed.content[index].key;
|
|
1067
1067
|
acc[key] = ts.EnumUsageKey(mappingPropertySchema.rawTypeData.$parsed.typeName, enumKey);
|
|
1068
1068
|
return acc;
|
|
@@ -1079,9 +1079,9 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1079
1079
|
...schema,
|
|
1080
1080
|
$ref: abstractSchemaStruct.component.$ref
|
|
1081
1081
|
};
|
|
1082
|
-
if (this.schemaUtils.getInternalSchemaType(schema) === SCHEMA_TYPES.OBJECT) for (const schemaPropertyName in schema.properties) {
|
|
1082
|
+
if (this.schemaUtils.getInternalSchemaType(schema) === SCHEMA_TYPES$1.OBJECT) for (const schemaPropertyName in schema.properties) {
|
|
1083
1083
|
const schemaProperty = schema.properties[schemaPropertyName];
|
|
1084
|
-
if (schemaPropertyName === discPropertyName && this.schemaUtils.getInternalSchemaType(schemaProperty) === SCHEMA_TYPES.ENUM && schemaProperty.enum.length === 1 && mappingPropertySchemaEnumKeysMap[schemaProperty.enum[0]]) schema.properties[schemaPropertyName] = this.schemaParserFabric.createSchema({ content: mappingPropertySchemaEnumKeysMap[schemaProperty.enum[0]] });
|
|
1084
|
+
if (schemaPropertyName === discPropertyName && this.schemaUtils.getInternalSchemaType(schemaProperty) === SCHEMA_TYPES$1.ENUM && schemaProperty.enum.length === 1 && mappingPropertySchemaEnumKeysMap[schemaProperty.enum[0]]) schema.properties[schemaPropertyName] = this.schemaParserFabric.createSchema({ content: mappingPropertySchemaEnumKeysMap[schemaProperty.enum[0]] });
|
|
1085
1085
|
}
|
|
1086
1086
|
return schema;
|
|
1087
1087
|
});
|
|
@@ -1120,7 +1120,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
|
|
|
1120
1120
|
createComplexSchemaStruct = () => {
|
|
1121
1121
|
const ts = this.config.Ts;
|
|
1122
1122
|
const complexType = this.schemaUtils.getComplexType(this.schema);
|
|
1123
|
-
if (complexType === SCHEMA_TYPES.COMPLEX_UNKNOWN) return null;
|
|
1123
|
+
if (complexType === SCHEMA_TYPES$1.COMPLEX_UNKNOWN) return null;
|
|
1124
1124
|
return { content: ts.ExpressionGroup(this.schemaParser._complexSchemaParsers[complexType](this.schema)) };
|
|
1125
1125
|
};
|
|
1126
1126
|
};
|
|
@@ -1223,8 +1223,8 @@ var EnumSchemaParser = class extends MonoSchemaParser {
|
|
|
1223
1223
|
$ref,
|
|
1224
1224
|
typeName: this.typeName || $ref && refType.typeName || null,
|
|
1225
1225
|
$parsedSchema: true,
|
|
1226
|
-
schemaType: SCHEMA_TYPES.ENUM,
|
|
1227
|
-
type: SCHEMA_TYPES.ENUM,
|
|
1226
|
+
schemaType: SCHEMA_TYPES$1.ENUM,
|
|
1227
|
+
type: SCHEMA_TYPES$1.ENUM,
|
|
1228
1228
|
keyType,
|
|
1229
1229
|
typeIdentifier: this.config.generateUnionEnums ? this.config.Ts.Keyword.Type : this.config.Ts.Keyword.Enum,
|
|
1230
1230
|
name: this.typeName,
|
|
@@ -1249,8 +1249,8 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
|
|
|
1249
1249
|
...typeof this.schema === "object" ? this.schema : {},
|
|
1250
1250
|
$schemaPath: this.schemaPath.slice(),
|
|
1251
1251
|
$parsedSchema: true,
|
|
1252
|
-
schemaType: SCHEMA_TYPES.OBJECT,
|
|
1253
|
-
type: SCHEMA_TYPES.OBJECT,
|
|
1252
|
+
schemaType: SCHEMA_TYPES$1.OBJECT,
|
|
1253
|
+
type: SCHEMA_TYPES$1.OBJECT,
|
|
1254
1254
|
typeIdentifier: this.config.Ts.Keyword.Interface,
|
|
1255
1255
|
name: this.typeName,
|
|
1256
1256
|
description: this.schemaFormatters.formatDescription(this.schema.description),
|
|
@@ -1332,7 +1332,7 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
|
1332
1332
|
...typeof this.schema === "object" ? this.schema : {},
|
|
1333
1333
|
oneOf: type$1.map((type$2) => ({ type: type$2 }))
|
|
1334
1334
|
});
|
|
1335
|
-
if (Array.isArray(items) && type$1 === SCHEMA_TYPES.ARRAY) contentType = this.config.Ts.Tuple(items.map((item) => this.schemaParserFabric.createSchemaParser({
|
|
1335
|
+
if (Array.isArray(items) && type$1 === SCHEMA_TYPES$1.ARRAY) contentType = this.config.Ts.Tuple(items.map((item) => this.schemaParserFabric.createSchemaParser({
|
|
1336
1336
|
schema: item,
|
|
1337
1337
|
schemaPath: this.schemaPath
|
|
1338
1338
|
}).getInlineParseContent()));
|
|
@@ -1340,8 +1340,8 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
|
|
|
1340
1340
|
...typeof this.schema === "object" ? this.schema : {},
|
|
1341
1341
|
$schemaPath: this.schemaPath.slice(),
|
|
1342
1342
|
$parsedSchema: true,
|
|
1343
|
-
schemaType: SCHEMA_TYPES.PRIMITIVE,
|
|
1344
|
-
type: SCHEMA_TYPES.PRIMITIVE,
|
|
1343
|
+
schemaType: SCHEMA_TYPES$1.PRIMITIVE,
|
|
1344
|
+
type: SCHEMA_TYPES$1.PRIMITIVE,
|
|
1345
1345
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
1346
1346
|
name: this.typeName,
|
|
1347
1347
|
description: this.schemaFormatters.formatDescription(description$1),
|
|
@@ -1422,67 +1422,67 @@ var SchemaParser = class {
|
|
|
1422
1422
|
this.schemaPath = [...schemaPath || []];
|
|
1423
1423
|
}
|
|
1424
1424
|
_complexSchemaParsers = {
|
|
1425
|
-
[SCHEMA_TYPES.COMPLEX_ONE_OF]: (schema) => {
|
|
1425
|
+
[SCHEMA_TYPES$1.COMPLEX_ONE_OF]: (schema) => {
|
|
1426
1426
|
const SchemaParser$1 = this.config.schemaParsers.complexOneOf || OneOfSchemaParser;
|
|
1427
1427
|
const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
|
|
1428
1428
|
return schemaParser.parse();
|
|
1429
1429
|
},
|
|
1430
|
-
[SCHEMA_TYPES.COMPLEX_ALL_OF]: (schema) => {
|
|
1430
|
+
[SCHEMA_TYPES$1.COMPLEX_ALL_OF]: (schema) => {
|
|
1431
1431
|
const SchemaParser$1 = this.config.schemaParsers.complexAllOf || AllOfSchemaParser;
|
|
1432
1432
|
const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
|
|
1433
1433
|
return schemaParser.parse();
|
|
1434
1434
|
},
|
|
1435
|
-
[SCHEMA_TYPES.COMPLEX_ANY_OF]: (schema) => {
|
|
1435
|
+
[SCHEMA_TYPES$1.COMPLEX_ANY_OF]: (schema) => {
|
|
1436
1436
|
const SchemaParser$1 = this.config.schemaParsers.complexAnyOf || AnyOfSchemaParser;
|
|
1437
1437
|
const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
|
|
1438
1438
|
return schemaParser.parse();
|
|
1439
1439
|
},
|
|
1440
|
-
[SCHEMA_TYPES.COMPLEX_NOT]: (schema) => {
|
|
1440
|
+
[SCHEMA_TYPES$1.COMPLEX_NOT]: (schema) => {
|
|
1441
1441
|
const SchemaParser$1 = this.config.schemaParsers.complexNot || NotSchemaParser;
|
|
1442
1442
|
const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
|
|
1443
1443
|
return schemaParser.parse();
|
|
1444
1444
|
}
|
|
1445
1445
|
};
|
|
1446
1446
|
_baseSchemaParsers = {
|
|
1447
|
-
[SCHEMA_TYPES.ENUM]: (schema, typeName) => {
|
|
1447
|
+
[SCHEMA_TYPES$1.ENUM]: (schema, typeName) => {
|
|
1448
1448
|
const SchemaParser$1 = this.config.schemaParsers.enum || EnumSchemaParser;
|
|
1449
1449
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1450
1450
|
return schemaParser.parse();
|
|
1451
1451
|
},
|
|
1452
|
-
[SCHEMA_TYPES.OBJECT]: (schema, typeName) => {
|
|
1452
|
+
[SCHEMA_TYPES$1.OBJECT]: (schema, typeName) => {
|
|
1453
1453
|
const SchemaParser$1 = this.config.schemaParsers.object || ObjectSchemaParser;
|
|
1454
1454
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1455
1455
|
return schemaParser.parse();
|
|
1456
1456
|
},
|
|
1457
|
-
[SCHEMA_TYPES.COMPLEX]: (schema, typeName) => {
|
|
1457
|
+
[SCHEMA_TYPES$1.COMPLEX]: (schema, typeName) => {
|
|
1458
1458
|
const SchemaParser$1 = this.config.schemaParsers.complex || ComplexSchemaParser;
|
|
1459
1459
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1460
1460
|
return schemaParser.parse();
|
|
1461
1461
|
},
|
|
1462
|
-
[SCHEMA_TYPES.PRIMITIVE]: (schema, typeName) => {
|
|
1462
|
+
[SCHEMA_TYPES$1.PRIMITIVE]: (schema, typeName) => {
|
|
1463
1463
|
const SchemaParser$1 = this.config.schemaParsers.primitive || PrimitiveSchemaParser;
|
|
1464
1464
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1465
1465
|
return schemaParser.parse();
|
|
1466
1466
|
},
|
|
1467
|
-
[SCHEMA_TYPES.DISCRIMINATOR]: (schema, typeName) => {
|
|
1467
|
+
[SCHEMA_TYPES$1.DISCRIMINATOR]: (schema, typeName) => {
|
|
1468
1468
|
const SchemaParser$1 = this.config.schemaParsers.discriminator || DiscriminatorSchemaParser;
|
|
1469
1469
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1470
1470
|
return schemaParser.parse();
|
|
1471
1471
|
},
|
|
1472
|
-
[SCHEMA_TYPES.ARRAY]: (schema, typeName) => {
|
|
1472
|
+
[SCHEMA_TYPES$1.ARRAY]: (schema, typeName) => {
|
|
1473
1473
|
const SchemaParser$1 = this.config.schemaParsers.array || ArraySchemaParser;
|
|
1474
1474
|
const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
|
|
1475
1475
|
return schemaParser.parse();
|
|
1476
1476
|
}
|
|
1477
1477
|
};
|
|
1478
1478
|
parseSchema = () => {
|
|
1479
|
-
if (!this.schema) return this._baseSchemaParsers[SCHEMA_TYPES.PRIMITIVE](null, this.typeName);
|
|
1479
|
+
if (!this.schema) return this._baseSchemaParsers[SCHEMA_TYPES$1.PRIMITIVE](null, this.typeName);
|
|
1480
1480
|
let schemaType = null;
|
|
1481
1481
|
let parsedSchema = null;
|
|
1482
1482
|
if (typeof this.schema === "string") return this.schema;
|
|
1483
1483
|
if (!this.schema.$parsed) {
|
|
1484
1484
|
if (!this.typeName && this.schemaUtils.isRefSchema(this.schema)) this.typeName = this.schemaUtils.getSchemaType(this.schema);
|
|
1485
|
-
if (this.schema.items && !Array.isArray(this.schema.items) && !this.schema.type) this.schema.type = SCHEMA_TYPES.ARRAY;
|
|
1485
|
+
if (this.schema.items && !Array.isArray(this.schema.items) && !this.schema.type) this.schema.type = SCHEMA_TYPES$1.ARRAY;
|
|
1486
1486
|
if (Array.isArray(this.schema.enum) && this.schema.enum.length === 1 && this.schema.enum[0] == null) {
|
|
1487
1487
|
consola.consola.debug("invalid enum schema", this.schema);
|
|
1488
1488
|
this.schema = { type: this.config.Ts.Keyword.Null };
|
|
@@ -1597,8 +1597,8 @@ var SchemaUtils = class {
|
|
|
1597
1597
|
if (enumFieldType === this.config.Ts.Keyword.Undefined) return;
|
|
1598
1598
|
return internalCase(enumFieldType);
|
|
1599
1599
|
}
|
|
1600
|
-
if (lodash.default.keys(schema.properties).length) return SCHEMA_TYPES.OBJECT;
|
|
1601
|
-
if (schema.items) return SCHEMA_TYPES.ARRAY;
|
|
1600
|
+
if (lodash.default.keys(schema.properties).length) return SCHEMA_TYPES$1.OBJECT;
|
|
1601
|
+
if (schema.items) return SCHEMA_TYPES$1.ARRAY;
|
|
1602
1602
|
return null;
|
|
1603
1603
|
};
|
|
1604
1604
|
checkAndAddRequiredKeys = (schema, resultType) => {
|
|
@@ -1642,19 +1642,19 @@ var SchemaUtils = class {
|
|
|
1642
1642
|
return this.config.componentTypeNameResolver.resolve([...(prefixes || []).map((prefix) => pascalCase(`${prefix} ${typeName}`)), ...(suffixes || []).map((suffix) => pascalCase(`${typeName} ${suffix}`))], shouldReserve);
|
|
1643
1643
|
};
|
|
1644
1644
|
getComplexType = (schema) => {
|
|
1645
|
-
if (schema.oneOf) return SCHEMA_TYPES.COMPLEX_ONE_OF;
|
|
1646
|
-
if (schema.allOf) return SCHEMA_TYPES.COMPLEX_ALL_OF;
|
|
1647
|
-
if (schema.anyOf) return SCHEMA_TYPES.COMPLEX_ANY_OF;
|
|
1648
|
-
if (schema.not) return SCHEMA_TYPES.COMPLEX_NOT;
|
|
1649
|
-
return SCHEMA_TYPES.COMPLEX_UNKNOWN;
|
|
1645
|
+
if (schema.oneOf) return SCHEMA_TYPES$1.COMPLEX_ONE_OF;
|
|
1646
|
+
if (schema.allOf) return SCHEMA_TYPES$1.COMPLEX_ALL_OF;
|
|
1647
|
+
if (schema.anyOf) return SCHEMA_TYPES$1.COMPLEX_ANY_OF;
|
|
1648
|
+
if (schema.not) return SCHEMA_TYPES$1.COMPLEX_NOT;
|
|
1649
|
+
return SCHEMA_TYPES$1.COMPLEX_UNKNOWN;
|
|
1650
1650
|
};
|
|
1651
1651
|
getInternalSchemaType = (schema) => {
|
|
1652
|
-
if (!lodash.default.isEmpty(schema.enum) || !lodash.default.isEmpty(this.getEnumNames(schema))) return SCHEMA_TYPES.ENUM;
|
|
1653
|
-
if (schema.discriminator) return SCHEMA_TYPES.DISCRIMINATOR;
|
|
1654
|
-
if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) return SCHEMA_TYPES.COMPLEX;
|
|
1655
|
-
if (!lodash.default.isEmpty(schema.properties)) return SCHEMA_TYPES.OBJECT;
|
|
1656
|
-
if (schema.type === SCHEMA_TYPES.ARRAY) return SCHEMA_TYPES.ARRAY;
|
|
1657
|
-
return SCHEMA_TYPES.PRIMITIVE;
|
|
1652
|
+
if (!lodash.default.isEmpty(schema.enum) || !lodash.default.isEmpty(this.getEnumNames(schema))) return SCHEMA_TYPES$1.ENUM;
|
|
1653
|
+
if (schema.discriminator) return SCHEMA_TYPES$1.DISCRIMINATOR;
|
|
1654
|
+
if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) return SCHEMA_TYPES$1.COMPLEX;
|
|
1655
|
+
if (!lodash.default.isEmpty(schema.properties)) return SCHEMA_TYPES$1.OBJECT;
|
|
1656
|
+
if (schema.type === SCHEMA_TYPES$1.ARRAY) return SCHEMA_TYPES$1.ARRAY;
|
|
1657
|
+
return SCHEMA_TYPES$1.PRIMITIVE;
|
|
1658
1658
|
};
|
|
1659
1659
|
getSchemaType = (schema) => {
|
|
1660
1660
|
if (!schema) return this.config.Ts.Keyword.Any;
|
|
@@ -3059,6 +3059,32 @@ var CodeGenProcess = class {
|
|
|
3059
3059
|
};
|
|
3060
3060
|
};
|
|
3061
3061
|
|
|
3062
|
+
//#endregion
|
|
3063
|
+
//#region types/index.ts
|
|
3064
|
+
let RequestContentKind = /* @__PURE__ */ function(RequestContentKind$1) {
|
|
3065
|
+
RequestContentKind$1["JSON"] = "JSON";
|
|
3066
|
+
RequestContentKind$1["URL_ENCODED"] = "URL_ENCODED";
|
|
3067
|
+
RequestContentKind$1["FORM_DATA"] = "FORM_DATA";
|
|
3068
|
+
RequestContentKind$1["IMAGE"] = "IMAGE";
|
|
3069
|
+
RequestContentKind$1["OTHER"] = "OTHER";
|
|
3070
|
+
RequestContentKind$1["TEXT"] = "TEXT";
|
|
3071
|
+
return RequestContentKind$1;
|
|
3072
|
+
}({});
|
|
3073
|
+
let SCHEMA_TYPES = /* @__PURE__ */ function(SCHEMA_TYPES$2) {
|
|
3074
|
+
SCHEMA_TYPES$2["ARRAY"] = "array";
|
|
3075
|
+
SCHEMA_TYPES$2["OBJECT"] = "object";
|
|
3076
|
+
SCHEMA_TYPES$2["ENUM"] = "enum";
|
|
3077
|
+
SCHEMA_TYPES$2["REF"] = "$ref";
|
|
3078
|
+
SCHEMA_TYPES$2["PRIMITIVE"] = "primitive";
|
|
3079
|
+
SCHEMA_TYPES$2["COMPLEX"] = "complex";
|
|
3080
|
+
SCHEMA_TYPES$2["COMPLEX_ONE_OF"] = "oneOf";
|
|
3081
|
+
SCHEMA_TYPES$2["COMPLEX_ANY_OF"] = "anyOf";
|
|
3082
|
+
SCHEMA_TYPES$2["COMPLEX_ALL_OF"] = "allOf";
|
|
3083
|
+
SCHEMA_TYPES$2["COMPLEX_NOT"] = "not";
|
|
3084
|
+
SCHEMA_TYPES$2["COMPLEX_UNKNOWN"] = "__unknown";
|
|
3085
|
+
return SCHEMA_TYPES$2;
|
|
3086
|
+
}({});
|
|
3087
|
+
|
|
3062
3088
|
//#endregion
|
|
3063
3089
|
//#region src/commands/generate-templates/configuration.ts
|
|
3064
3090
|
var TemplatesGenConfig = class {
|
|
@@ -3212,6 +3238,18 @@ Object.defineProperty(exports, 'HTTP_CLIENT', {
|
|
|
3212
3238
|
return HTTP_CLIENT;
|
|
3213
3239
|
}
|
|
3214
3240
|
});
|
|
3241
|
+
Object.defineProperty(exports, 'RequestContentKind', {
|
|
3242
|
+
enumerable: true,
|
|
3243
|
+
get: function () {
|
|
3244
|
+
return RequestContentKind;
|
|
3245
|
+
}
|
|
3246
|
+
});
|
|
3247
|
+
Object.defineProperty(exports, 'SCHEMA_TYPES', {
|
|
3248
|
+
enumerable: true,
|
|
3249
|
+
get: function () {
|
|
3250
|
+
return SCHEMA_TYPES;
|
|
3251
|
+
}
|
|
3252
|
+
});
|
|
3215
3253
|
Object.defineProperty(exports, 'TemplatesGenConfig', {
|
|
3216
3254
|
enumerable: true,
|
|
3217
3255
|
get: function () {
|
|
@@ -3248,4 +3286,4 @@ Object.defineProperty(exports, 'package_default', {
|
|
|
3248
3286
|
return package_default;
|
|
3249
3287
|
}
|
|
3250
3288
|
});
|
|
3251
|
-
//# sourceMappingURL=src-
|
|
3289
|
+
//# sourceMappingURL=src-C5bMYV9w.cjs.map
|