swagger-typescript-api 13.2.7 → 13.2.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/CHANGELOG.md +54 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +2 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +205 -16
- package/dist/lib.d.ts +205 -16
- package/dist/lib.js +1 -1
- package/dist/{src-DYNtMxii.cjs → src-B-cU8h_Y.cjs} +41 -29
- package/dist/src-B-cU8h_Y.cjs.map +1 -0
- package/dist/{src-BgBqKQNC.js → src-BGOGeWR6.js} +105 -100
- package/dist/src-BGOGeWR6.js.map +1 -0
- package/package.json +13 -13
- package/templates/base/http-clients/fetch-http-client.ejs +9 -4
- package/templates/base/route-type.ejs +2 -1
- package/templates/default/procedure-call.ejs +3 -1
- package/templates/modular/procedure-call.ejs +4 -2
- package/dist/src-BgBqKQNC.js.map +0 -1
- package/dist/src-DYNtMxii.cjs.map +0 -1
package/dist/lib.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as lodash14 from "lodash";
|
|
1
|
+
import * as lodash0 from "lodash";
|
|
3
2
|
import lodash from "lodash";
|
|
4
|
-
import * as typescript$1 from "typescript";
|
|
5
3
|
import * as typescript from "typescript";
|
|
6
|
-
import * as
|
|
4
|
+
import * as eta0 from "eta";
|
|
7
5
|
import { OpenAPI } from "openapi-types";
|
|
8
|
-
import * as
|
|
6
|
+
import * as swagger_schema_official0 from "swagger-schema-official";
|
|
9
7
|
|
|
10
8
|
//#region src/schema-components-map.d.ts
|
|
11
9
|
declare class SchemaComponentsMap {
|
|
@@ -379,7 +377,7 @@ declare class JavascriptTranslator extends Translator {
|
|
|
379
377
|
compileTSCode: (input: TranslatorIO) => Record<string, string>;
|
|
380
378
|
translate: (input: any) => Promise<{
|
|
381
379
|
fileName: any;
|
|
382
|
-
fileExtension: typescript
|
|
380
|
+
fileExtension: typescript.Extension;
|
|
383
381
|
fileContent: string;
|
|
384
382
|
}[]>;
|
|
385
383
|
}
|
|
@@ -528,7 +526,7 @@ declare class CodeGenProcess {
|
|
|
528
526
|
}) => string;
|
|
529
527
|
NameResolver: typeof NameResolver;
|
|
530
528
|
_: lodash.LoDashStatic;
|
|
531
|
-
require: (packageOrPath: string) =>
|
|
529
|
+
require: (packageOrPath: string) => any;
|
|
532
530
|
};
|
|
533
531
|
};
|
|
534
532
|
getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
|
|
@@ -633,7 +631,7 @@ declare class CodeGenProcess {
|
|
|
633
631
|
}) => string;
|
|
634
632
|
NameResolver: typeof NameResolver;
|
|
635
633
|
_: lodash.LoDashStatic;
|
|
636
|
-
require: (packageOrPath: string) =>
|
|
634
|
+
require: (packageOrPath: string) => any;
|
|
637
635
|
};
|
|
638
636
|
config: CodeGenConfig;
|
|
639
637
|
};
|
|
@@ -670,7 +668,7 @@ declare class TemplatesWorker {
|
|
|
670
668
|
getTemplatePaths: (config: CodeGenConfig) => CodeGenConfig["templatePaths"];
|
|
671
669
|
cropExtension: (path: string) => string;
|
|
672
670
|
getTemplateFullPath: (path_: string, fileName: string) => string | undefined;
|
|
673
|
-
requireFnFromTemplate: (packageOrPath: string) =>
|
|
671
|
+
requireFnFromTemplate: (packageOrPath: string) => any;
|
|
674
672
|
getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
|
|
675
673
|
getTemplates: ({
|
|
676
674
|
templatePaths
|
|
@@ -774,6 +772,54 @@ declare class MonoSchemaParser {
|
|
|
774
772
|
//#endregion
|
|
775
773
|
//#region types/index.d.ts
|
|
776
774
|
type HttpClientType = (typeof HTTP_CLIENT)[keyof typeof HTTP_CLIENT];
|
|
775
|
+
type CodeGenConstruct = {
|
|
776
|
+
Keyword: {
|
|
777
|
+
Number: string;
|
|
778
|
+
String: string;
|
|
779
|
+
Boolean: string;
|
|
780
|
+
Any: string;
|
|
781
|
+
Void: string;
|
|
782
|
+
Unknown: string;
|
|
783
|
+
Null: string;
|
|
784
|
+
Undefined: string;
|
|
785
|
+
Object: string;
|
|
786
|
+
File: string;
|
|
787
|
+
Date: string;
|
|
788
|
+
Type: string;
|
|
789
|
+
Enum: string;
|
|
790
|
+
Interface: string;
|
|
791
|
+
Array: string;
|
|
792
|
+
Record: string;
|
|
793
|
+
Intersection: string;
|
|
794
|
+
Union: string;
|
|
795
|
+
};
|
|
796
|
+
CodeGenKeyword: {
|
|
797
|
+
UtilRequiredKeys: string;
|
|
798
|
+
};
|
|
799
|
+
ArrayType: (content: unknown) => string;
|
|
800
|
+
StringValue: (content: unknown) => string;
|
|
801
|
+
BooleanValue: (content: unknown) => string;
|
|
802
|
+
NumberValue: (content: unknown) => string;
|
|
803
|
+
NullValue: (content: unknown) => string;
|
|
804
|
+
UnionType: (content: unknown) => string;
|
|
805
|
+
ExpressionGroup: (content: unknown) => string;
|
|
806
|
+
IntersectionType: (content: unknown) => string;
|
|
807
|
+
RecordType: (content: unknown) => string;
|
|
808
|
+
TypeField: (content: unknown) => string;
|
|
809
|
+
InterfaceDynamicField: (content: unknown) => string;
|
|
810
|
+
EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
|
|
811
|
+
EnumField: (content: unknown) => string;
|
|
812
|
+
EnumFieldDescription: (content: unknown) => string;
|
|
813
|
+
EnumFieldsWrapper: (content: unknown) => string;
|
|
814
|
+
ObjectWrapper: (content: unknown) => string;
|
|
815
|
+
MultilineComment: (content: unknown) => string;
|
|
816
|
+
TypeWithGeneric: (content: unknown) => string;
|
|
817
|
+
Tuple: (content: unknown) => string;
|
|
818
|
+
};
|
|
819
|
+
type PrimitiveTypeStructValue = string | ((schema: Record<string, unknown>, parser: SchemaParser) => string);
|
|
820
|
+
type PrimitiveTypeStruct = Record<"integer" | "number" | "boolean" | "object" | "file" | "string" | "array", string | ({
|
|
821
|
+
$default: PrimitiveTypeStructValue;
|
|
822
|
+
} & Record<string, PrimitiveTypeStructValue>)>;
|
|
777
823
|
type BuildRouteParam = {
|
|
778
824
|
/** {bar} */
|
|
779
825
|
$match: string;
|
|
@@ -909,7 +955,7 @@ type RawRouteInfo = {
|
|
|
909
955
|
description?: string;
|
|
910
956
|
tags?: string[];
|
|
911
957
|
summary?: string;
|
|
912
|
-
responses?:
|
|
958
|
+
responses?: swagger_schema_official0.Spec["responses"];
|
|
913
959
|
produces?: string[];
|
|
914
960
|
requestBody?: object;
|
|
915
961
|
consumes?: string[];
|
|
@@ -1012,18 +1058,45 @@ type ExtractingOptions = {
|
|
|
1012
1058
|
};
|
|
1013
1059
|
interface GenerateApiConfiguration {
|
|
1014
1060
|
apiConfig: {
|
|
1061
|
+
/** base url from schema */
|
|
1015
1062
|
baseUrl: string;
|
|
1063
|
+
/** document title */
|
|
1016
1064
|
title: string;
|
|
1065
|
+
/** document version */
|
|
1017
1066
|
version: string;
|
|
1067
|
+
/** description split into lines */
|
|
1018
1068
|
description: string[];
|
|
1069
|
+
/** flag that description is present */
|
|
1019
1070
|
hasDescription: boolean;
|
|
1020
1071
|
};
|
|
1021
1072
|
config: {
|
|
1073
|
+
/** path to swagger schema */
|
|
1022
1074
|
input: string;
|
|
1075
|
+
/**
|
|
1076
|
+
* generate separated files for http client, data contracts, and routes
|
|
1077
|
+
* @default false
|
|
1078
|
+
*/
|
|
1079
|
+
modular: boolean;
|
|
1080
|
+
/**
|
|
1081
|
+
* path to folder where the created api module will be placed.
|
|
1082
|
+
* may be set to `false` to skip writing content to disk; in this case
|
|
1083
|
+
* the `files` array on the return value will contain the generated contents.
|
|
1084
|
+
*/
|
|
1023
1085
|
output: string | false;
|
|
1086
|
+
/** url to swagger schema */
|
|
1024
1087
|
url: string;
|
|
1088
|
+
/** swagger schema JSON */
|
|
1025
1089
|
spec: unknown;
|
|
1090
|
+
/**
|
|
1091
|
+
* file name for the generated API module
|
|
1092
|
+
* @default 'Api.ts'
|
|
1093
|
+
*/
|
|
1026
1094
|
fileName: string;
|
|
1095
|
+
/**
|
|
1096
|
+
* path to folder containing custom templates
|
|
1097
|
+
* @default ""
|
|
1098
|
+
*/
|
|
1099
|
+
templates: string;
|
|
1027
1100
|
templatePaths: {
|
|
1028
1101
|
/** `templates/base` */
|
|
1029
1102
|
base: string;
|
|
@@ -1036,66 +1109,176 @@ interface GenerateApiConfiguration {
|
|
|
1036
1109
|
/** custom path to templates (`--templates`) */
|
|
1037
1110
|
custom: string | null;
|
|
1038
1111
|
};
|
|
1112
|
+
/** authorisation token for private swagger schema access */
|
|
1039
1113
|
authorizationToken?: string;
|
|
1114
|
+
/** generate additional information about request responses and error typings */
|
|
1040
1115
|
generateResponses: boolean;
|
|
1116
|
+
/**
|
|
1117
|
+
* use "default" response status code as success response.
|
|
1118
|
+
* some swagger schemas treat "default" as a successful response.
|
|
1119
|
+
*/
|
|
1041
1120
|
defaultResponseAsSuccess: boolean;
|
|
1121
|
+
/** generate type definitions for API routes */
|
|
1042
1122
|
generateRouteTypes: boolean;
|
|
1123
|
+
/** generate an API client */
|
|
1043
1124
|
generateClient: boolean;
|
|
1125
|
+
/** generate all "enum" types as union types (T1 | T2 | TN) */
|
|
1044
1126
|
generateUnionEnums: boolean;
|
|
1127
|
+
/** parsed swagger schema */
|
|
1045
1128
|
swaggerSchema: object;
|
|
1129
|
+
/** original swagger schema */
|
|
1046
1130
|
originalSchema: object;
|
|
1131
|
+
/** map of schema component references */
|
|
1047
1132
|
componentsMap: Record<string, SchemaComponent>;
|
|
1133
|
+
/** flag indicating the schema was converted from Swagger 2.0 */
|
|
1048
1134
|
convertedFromSwagger2: boolean;
|
|
1135
|
+
/** determines which path index should be used for routes separation */
|
|
1049
1136
|
moduleNameIndex: number;
|
|
1137
|
+
/** use the first tag for the module name */
|
|
1050
1138
|
moduleNameFirstTag: boolean;
|
|
1139
|
+
/** extra templates */
|
|
1051
1140
|
extraTemplates: {
|
|
1052
1141
|
name: string;
|
|
1053
1142
|
path: string;
|
|
1054
1143
|
}[];
|
|
1144
|
+
/** extract request params to data contract */
|
|
1055
1145
|
extractRequestParams: boolean;
|
|
1146
|
+
/** unwrap the data item from the response */
|
|
1056
1147
|
unwrapResponseData: boolean;
|
|
1148
|
+
/** sort data contracts in alphabetical order */
|
|
1057
1149
|
sortTypes: boolean;
|
|
1150
|
+
/** sort routes in alphabetical order */
|
|
1058
1151
|
sortRoutes: boolean;
|
|
1152
|
+
/** ability to send HttpClient instance to Api constructor */
|
|
1059
1153
|
singleHttpClient: boolean;
|
|
1154
|
+
/** prefix string value for type names */
|
|
1060
1155
|
typePrefix: string;
|
|
1156
|
+
/** suffix string value for type names */
|
|
1061
1157
|
typeSuffix: string;
|
|
1158
|
+
/** prefix string value for enum keys */
|
|
1062
1159
|
enumKeyPrefix: string;
|
|
1160
|
+
/** suffix string value for enum keys */
|
|
1063
1161
|
enumKeySuffix: string;
|
|
1162
|
+
/** fix up small errors in the swagger source definition */
|
|
1064
1163
|
patch: boolean;
|
|
1164
|
+
/** remove output directory before generating */
|
|
1065
1165
|
cleanOutput: boolean;
|
|
1166
|
+
/** output debug messages */
|
|
1066
1167
|
debug: boolean;
|
|
1168
|
+
/**
|
|
1169
|
+
* generate array types as Array<Type>
|
|
1170
|
+
* @default false
|
|
1171
|
+
*/
|
|
1067
1172
|
anotherArrayType: boolean;
|
|
1173
|
+
/** extract request body type to data contract */
|
|
1068
1174
|
extractRequestBody: boolean;
|
|
1175
|
+
/** generated http client type */
|
|
1069
1176
|
httpClientType: "axios" | "fetch";
|
|
1177
|
+
/** generate readonly properties */
|
|
1070
1178
|
addReadonly: boolean;
|
|
1179
|
+
/** customise primitive type mappings */
|
|
1180
|
+
primitiveTypeConstructs?: (struct: PrimitiveTypeStruct) => Partial<PrimitiveTypeStruct>;
|
|
1181
|
+
/** customise code generation constructs */
|
|
1182
|
+
codeGenConstructs?: (struct: CodeGenConstruct) => Partial<CodeGenConstruct>;
|
|
1183
|
+
/** extract response body type to data contract */
|
|
1071
1184
|
extractResponseBody: boolean;
|
|
1185
|
+
/** extract response error type to data contract */
|
|
1072
1186
|
extractResponseError: boolean;
|
|
1187
|
+
/** extract all enums from nested types/interfaces to `enum` construction */
|
|
1073
1188
|
extractEnums: boolean;
|
|
1189
|
+
/** extract all enums from inline interface/type content to typescript enum construction */
|
|
1074
1190
|
extractResponses: boolean;
|
|
1191
|
+
/**
|
|
1192
|
+
* prefix string value needed to fix invalid type names
|
|
1193
|
+
* @default "Type"
|
|
1194
|
+
*/
|
|
1075
1195
|
fixInvalidTypeNamePrefix: string;
|
|
1196
|
+
/**
|
|
1197
|
+
* prefix string value needed to fix invalid enum keys
|
|
1198
|
+
* @default "Value"
|
|
1199
|
+
*/
|
|
1076
1200
|
fixInvalidEnumKeyPrefix: string;
|
|
1201
|
+
/**
|
|
1202
|
+
* default type for empty response schema
|
|
1203
|
+
* @default "void"
|
|
1204
|
+
*/
|
|
1077
1205
|
defaultResponseType: string;
|
|
1206
|
+
/**
|
|
1207
|
+
* generate js api module with declaration file
|
|
1208
|
+
* @default false
|
|
1209
|
+
*/
|
|
1078
1210
|
toJS: boolean;
|
|
1211
|
+
/** disable throwing on a non-successful response */
|
|
1079
1212
|
disableThrowOnError: boolean;
|
|
1213
|
+
/**
|
|
1214
|
+
* output only errors to console
|
|
1215
|
+
* @default false
|
|
1216
|
+
*/
|
|
1080
1217
|
silent: boolean;
|
|
1218
|
+
/** hooks for customising the generation process */
|
|
1081
1219
|
hooks: Partial<Hooks>;
|
|
1220
|
+
/** use enum names as values */
|
|
1082
1221
|
enumNamesAsValues: boolean;
|
|
1222
|
+
/** package version */
|
|
1083
1223
|
version: string;
|
|
1224
|
+
/** ts compiler configuration object (for --to-js option) */
|
|
1084
1225
|
compilerTsConfig: Record<string, unknown>;
|
|
1226
|
+
/** enum key resolver name */
|
|
1085
1227
|
enumKeyResolverName: string;
|
|
1228
|
+
/** type name resolver name */
|
|
1086
1229
|
typeNameResolverName: string;
|
|
1230
|
+
/** specific argument name resolver name */
|
|
1087
1231
|
specificArgNameResolverName: string;
|
|
1232
|
+
/**
|
|
1233
|
+
* custom ts->* translator
|
|
1234
|
+
* do not use constructor args, just send class reference
|
|
1235
|
+
*/
|
|
1088
1236
|
customTranslator?: new () => Translator;
|
|
1237
|
+
/** internal constants */
|
|
1238
|
+
constants: typeof constants_d_exports;
|
|
1239
|
+
/** code generation constructs for TypeScript */
|
|
1240
|
+
Ts: CodeGenConstruct;
|
|
1241
|
+
/**
|
|
1242
|
+
* swagger schema type -> typescript type
|
|
1243
|
+
* https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times
|
|
1244
|
+
*/
|
|
1245
|
+
primitiveTypes: PrimitiveTypeStruct;
|
|
1246
|
+
/** built-in template info */
|
|
1247
|
+
templateInfos: {
|
|
1248
|
+
name: string;
|
|
1249
|
+
fileName: string;
|
|
1250
|
+
}[];
|
|
1251
|
+
/** supported template file extensions */
|
|
1252
|
+
templateExtensions: string[];
|
|
1253
|
+
/** range of HTTP status codes treated as success */
|
|
1254
|
+
successResponseStatusRange: [number, number];
|
|
1255
|
+
/** custom schema parsers */
|
|
1256
|
+
schemaParsers?: {
|
|
1257
|
+
complexOneOf?: MonoSchemaParser;
|
|
1258
|
+
complexAllOf?: MonoSchemaParser;
|
|
1259
|
+
complexAnyOf?: MonoSchemaParser;
|
|
1260
|
+
complexNot?: MonoSchemaParser;
|
|
1261
|
+
enum?: MonoSchemaParser;
|
|
1262
|
+
object?: MonoSchemaParser;
|
|
1263
|
+
complex?: MonoSchemaParser;
|
|
1264
|
+
primitive?: MonoSchemaParser;
|
|
1265
|
+
discriminator?: MonoSchemaParser;
|
|
1266
|
+
array?: MonoSchemaParser;
|
|
1267
|
+
};
|
|
1268
|
+
/** internal options for templates */
|
|
1089
1269
|
internalTemplateOptions: {
|
|
1090
1270
|
addUtilRequiredKeysType: boolean;
|
|
1091
1271
|
};
|
|
1272
|
+
/** resolver for component type names */
|
|
1092
1273
|
componentTypeNameResolver: ComponentTypeNameResolver;
|
|
1274
|
+
/** generated file names */
|
|
1093
1275
|
fileNames: {
|
|
1094
1276
|
dataContracts: string;
|
|
1095
1277
|
routeTypes: string;
|
|
1096
1278
|
httpClient: string;
|
|
1097
1279
|
outOfModuleApi: string;
|
|
1098
1280
|
};
|
|
1281
|
+
/** Record<templateName, templateContent> */
|
|
1099
1282
|
templatesToRender: {
|
|
1100
1283
|
api: string;
|
|
1101
1284
|
dataContracts: string;
|
|
@@ -1108,10 +1291,16 @@ interface GenerateApiConfiguration {
|
|
|
1108
1291
|
enumDataContract: string;
|
|
1109
1292
|
objectFieldJsDoc: string;
|
|
1110
1293
|
};
|
|
1294
|
+
/** map of duplicate route names */
|
|
1111
1295
|
routeNameDuplicatesMap: Map<string, string>;
|
|
1296
|
+
/** name of the main exported class */
|
|
1112
1297
|
apiClassName: string;
|
|
1113
|
-
|
|
1114
|
-
|
|
1298
|
+
/** configuration for fetching swagger schema requests */
|
|
1299
|
+
requestOptions?: Partial<RequestInit>;
|
|
1300
|
+
/** extra configuration for extracting type names operations */
|
|
1301
|
+
extractingOptions: Partial<ExtractingOptions>;
|
|
1302
|
+
/** update configuration object during generation */
|
|
1303
|
+
update: (update: Partial<GenerateApiConfiguration["config"]>) => void;
|
|
1115
1304
|
};
|
|
1116
1305
|
modelTypes: ModelType[];
|
|
1117
1306
|
hasFormDataRoutes: boolean;
|
|
@@ -1142,7 +1331,7 @@ interface GenerateApiConfiguration {
|
|
|
1142
1331
|
fmtToJSDocLine: (line: string, params?: {
|
|
1143
1332
|
eol?: boolean;
|
|
1144
1333
|
}) => string;
|
|
1145
|
-
_:
|
|
1334
|
+
_: lodash0.LoDashStatic;
|
|
1146
1335
|
require: (path: string) => unknown;
|
|
1147
1336
|
};
|
|
1148
1337
|
}
|
|
@@ -1163,7 +1352,7 @@ interface GenerateApiOutput {
|
|
|
1163
1352
|
content: string;
|
|
1164
1353
|
withPrefix: boolean;
|
|
1165
1354
|
}) => void;
|
|
1166
|
-
renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<
|
|
1355
|
+
renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<eta0.EtaConfig>) => Promise<string> | string;
|
|
1167
1356
|
getTemplate: (params: {
|
|
1168
1357
|
fileName?: string;
|
|
1169
1358
|
name?: string;
|
|
@@ -1585,8 +1774,8 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1585
1774
|
eol?: boolean | undefined;
|
|
1586
1775
|
}) => string;
|
|
1587
1776
|
NameResolver: typeof NameResolver;
|
|
1588
|
-
_:
|
|
1589
|
-
require: (packageOrPath: string) =>
|
|
1777
|
+
_: lodash0.LoDashStatic;
|
|
1778
|
+
require: (packageOrPath: string) => any;
|
|
1590
1779
|
};
|
|
1591
1780
|
};
|
|
1592
1781
|
getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
|
package/dist/lib.js
CHANGED
|
@@ -35,6 +35,7 @@ const __biomejs_js_api = __toESM(require("@biomejs/js-api"));
|
|
|
35
35
|
const nanoid = __toESM(require("nanoid"));
|
|
36
36
|
const js_yaml = __toESM(require("js-yaml"));
|
|
37
37
|
const swagger2openapi = __toESM(require("swagger2openapi"));
|
|
38
|
+
const node_module = __toESM(require("node:module"));
|
|
38
39
|
const node_url = __toESM(require("node:url"));
|
|
39
40
|
const eta = __toESM(require("eta"));
|
|
40
41
|
const node_fs = __toESM(require("node:fs"));
|
|
@@ -181,7 +182,7 @@ const getRandomInt = (min = 0, max = 1) => {
|
|
|
181
182
|
var ComponentTypeNameResolver = class extends NameResolver {
|
|
182
183
|
counter = 1;
|
|
183
184
|
fallbackNameCounter = 1;
|
|
184
|
-
countersByVariant = new Map();
|
|
185
|
+
countersByVariant = /* @__PURE__ */ new Map();
|
|
185
186
|
constructor(config, reservedNames) {
|
|
186
187
|
super(config, reservedNames, (variants) => {
|
|
187
188
|
const randomVariant = variants[getRandomInt(0, variants.length - 1)];
|
|
@@ -203,7 +204,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
203
204
|
//#endregion
|
|
204
205
|
//#region package.json
|
|
205
206
|
var name = "swagger-typescript-api";
|
|
206
|
-
var version = "13.2.
|
|
207
|
+
var version = "13.2.9";
|
|
207
208
|
var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
|
|
208
209
|
var homepage = "https://github.com/acacode/swagger-typescript-api";
|
|
209
210
|
var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
|
|
@@ -243,10 +244,10 @@ var scripts = {
|
|
|
243
244
|
"typedoc": "typedoc"
|
|
244
245
|
};
|
|
245
246
|
var dependencies = {
|
|
246
|
-
"@biomejs/js-api": "
|
|
247
|
-
"@biomejs/wasm-nodejs": "2.
|
|
247
|
+
"@biomejs/js-api": "3.0.0",
|
|
248
|
+
"@biomejs/wasm-nodejs": "2.2.2",
|
|
248
249
|
"@types/swagger-schema-official": "^2.0.25",
|
|
249
|
-
"c12": "^3.0
|
|
250
|
+
"c12": "^3.2.0",
|
|
250
251
|
"citty": "^0.1.6",
|
|
251
252
|
"consola": "^3.4.2",
|
|
252
253
|
"eta": "^2.2.0",
|
|
@@ -255,25 +256,25 @@ var dependencies = {
|
|
|
255
256
|
"nanoid": "^5.1.5",
|
|
256
257
|
"swagger-schema-official": "2.0.0-bab6bed",
|
|
257
258
|
"swagger2openapi": "^7.0.8",
|
|
258
|
-
"typescript": "~5.
|
|
259
|
+
"typescript": "~5.9.2"
|
|
259
260
|
};
|
|
260
261
|
var devDependencies = {
|
|
261
|
-
"@biomejs/biome": "2.
|
|
262
|
+
"@biomejs/biome": "2.2.2",
|
|
262
263
|
"@changesets/changelog-github": "0.5.1",
|
|
263
|
-
"@changesets/cli": "2.29.
|
|
264
|
+
"@changesets/cli": "2.29.6",
|
|
264
265
|
"@tsconfig/node18": "18.2.4",
|
|
265
266
|
"@tsconfig/strictest": "2.0.5",
|
|
266
267
|
"@types/js-yaml": "4.0.9",
|
|
267
|
-
"@types/lodash": "4.17.
|
|
268
|
-
"@types/node": "24.0
|
|
268
|
+
"@types/lodash": "4.17.20",
|
|
269
|
+
"@types/node": "24.3.0",
|
|
269
270
|
"@types/swagger2openapi": "7.0.4",
|
|
270
|
-
"axios": "1.
|
|
271
|
+
"axios": "1.11.0",
|
|
271
272
|
"openapi-types": "12.1.3",
|
|
272
|
-
"tsdown": "0.
|
|
273
|
-
"typedoc": "0.28.
|
|
273
|
+
"tsdown": "0.14.2",
|
|
274
|
+
"typedoc": "0.28.11",
|
|
274
275
|
"vitest": "3.2.4"
|
|
275
276
|
};
|
|
276
|
-
var packageManager = "yarn@4.9.
|
|
277
|
+
var packageManager = "yarn@4.9.4";
|
|
277
278
|
var engines = { "node": ">=20" };
|
|
278
279
|
var publishConfig = {
|
|
279
280
|
"access": "public",
|
|
@@ -452,7 +453,7 @@ var CodeGenConfig = class {
|
|
|
452
453
|
httpClient: "http-client",
|
|
453
454
|
outOfModuleApi: "Common"
|
|
454
455
|
};
|
|
455
|
-
routeNameDuplicatesMap = new Map();
|
|
456
|
+
routeNameDuplicatesMap = /* @__PURE__ */ new Map();
|
|
456
457
|
hooks = {
|
|
457
458
|
onPreBuildRoutePath: (_routePath) => void 0,
|
|
458
459
|
onBuildRoutePath: (_routeData) => void 0,
|
|
@@ -719,6 +720,7 @@ var CodeGenConfig = class {
|
|
|
719
720
|
}
|
|
720
721
|
update = (update) => {
|
|
721
722
|
objectAssign(this, update);
|
|
723
|
+
if (this.enumNamesAsValues) this.extractEnums = true;
|
|
722
724
|
};
|
|
723
725
|
};
|
|
724
726
|
|
|
@@ -1175,9 +1177,19 @@ var EnumSchemaParser = class extends MonoSchemaParser {
|
|
|
1175
1177
|
let content = null;
|
|
1176
1178
|
const formatValue = (value) => {
|
|
1177
1179
|
if (value === null) return this.config.Ts.NullValue(value);
|
|
1178
|
-
if (keyType.includes(this.schemaUtils.getSchemaType({ type: "number" })))
|
|
1179
|
-
|
|
1180
|
-
|
|
1180
|
+
if (keyType.includes(this.schemaUtils.getSchemaType({ type: "number" }))) {
|
|
1181
|
+
const maybeNumber = typeof value === "number" ? value : Number(value);
|
|
1182
|
+
if (!Number.isNaN(maybeNumber)) return this.config.Ts.NumberValue(maybeNumber);
|
|
1183
|
+
}
|
|
1184
|
+
if (keyType.includes(this.schemaUtils.getSchemaType({ type: "boolean" }))) {
|
|
1185
|
+
if (typeof value === "boolean") return this.config.Ts.BooleanValue(value);
|
|
1186
|
+
if (value === "true" || value === "false") return this.config.Ts.BooleanValue(value === "true");
|
|
1187
|
+
}
|
|
1188
|
+
switch (typeof value) {
|
|
1189
|
+
case "number": return this.config.Ts.NumberValue(value);
|
|
1190
|
+
case "boolean": return this.config.Ts.BooleanValue(value);
|
|
1191
|
+
default: return this.config.Ts.StringValue(value);
|
|
1192
|
+
}
|
|
1181
1193
|
};
|
|
1182
1194
|
if (Array.isArray(enumNames) && lodash.default.size(enumNames)) content = enumNames.map((enumName, index) => {
|
|
1183
1195
|
const enumValue = lodash.default.get(this.schema.enum, index);
|
|
@@ -1649,7 +1661,7 @@ var SchemaUtils = class {
|
|
|
1649
1661
|
const refTypeInfo = this.getSchemaRefType(schema);
|
|
1650
1662
|
if (refTypeInfo) return this.checkAndAddRequiredKeys(schema, this.safeAddNullToType(schema, this.typeNameFormatter.format(refTypeInfo.typeName)));
|
|
1651
1663
|
let resultType;
|
|
1652
|
-
if (this.isConstantSchema(schema)) resultType = this.formatJsValue(schema.const);
|
|
1664
|
+
if (this.isConstantSchema(schema) && !schema.enum) resultType = this.formatJsValue(schema.const);
|
|
1653
1665
|
else {
|
|
1654
1666
|
const primitiveType = this.getSchemaPrimitiveType(schema);
|
|
1655
1667
|
if (primitiveType == null) return this.config.Ts.Keyword.Any;
|
|
@@ -1673,10 +1685,9 @@ var SchemaUtils = class {
|
|
|
1673
1685
|
case "string": return this.config.Ts.StringValue(value);
|
|
1674
1686
|
case "boolean": return this.config.Ts.BooleanValue(value);
|
|
1675
1687
|
case "number": return this.config.Ts.NumberValue(value);
|
|
1676
|
-
default:
|
|
1688
|
+
default:
|
|
1677
1689
|
if (value === null) return this.config.Ts.NullValue(value);
|
|
1678
1690
|
return this.config.Ts.Keyword.Any;
|
|
1679
|
-
}
|
|
1680
1691
|
}
|
|
1681
1692
|
};
|
|
1682
1693
|
};
|
|
@@ -2075,7 +2086,7 @@ var SchemaRoutes = class {
|
|
|
2075
2086
|
};
|
|
2076
2087
|
};
|
|
2077
2088
|
createRequestParamsSchema = ({ queryParams, queryObjectSchema, pathArgsSchemas, extractRequestParams, routeName }) => {
|
|
2078
|
-
if (!queryParams || !queryParams.length) return null;
|
|
2089
|
+
if ((!queryParams || !queryParams.length) && (!pathArgsSchemas || !pathArgsSchemas.length)) return null;
|
|
2079
2090
|
const pathParams = pathArgsSchemas.reduce((acc, pathArgSchema) => {
|
|
2080
2091
|
if (pathArgSchema.name) acc[pathArgSchema.name] = {
|
|
2081
2092
|
...pathArgSchema,
|
|
@@ -2368,8 +2379,8 @@ var SchemaRoutes = class {
|
|
|
2368
2379
|
var SchemaWalker = class {
|
|
2369
2380
|
config;
|
|
2370
2381
|
swaggerSchemaResolver;
|
|
2371
|
-
schemas = new Map();
|
|
2372
|
-
caches = new Map();
|
|
2382
|
+
schemas = /* @__PURE__ */ new Map();
|
|
2383
|
+
caches = /* @__PURE__ */ new Map();
|
|
2373
2384
|
constructor(config, swaggerSchemaResolver) {
|
|
2374
2385
|
this.config = config;
|
|
2375
2386
|
this.swaggerSchemaResolver = swaggerSchemaResolver;
|
|
@@ -2505,6 +2516,7 @@ var SwaggerSchemaResolver = class {
|
|
|
2505
2516
|
|
|
2506
2517
|
//#endregion
|
|
2507
2518
|
//#region src/templates-worker.ts
|
|
2519
|
+
const require$1 = node_module.createRequire(require("url").pathToFileURL(__filename).href);
|
|
2508
2520
|
var TemplatesWorker = class {
|
|
2509
2521
|
config;
|
|
2510
2522
|
fileSystem;
|
|
@@ -2537,10 +2549,10 @@ var TemplatesWorker = class {
|
|
|
2537
2549
|
const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
|
|
2538
2550
|
return pathVariants.find((variant) => !!this.fileSystem.pathIsExist(variant));
|
|
2539
2551
|
};
|
|
2540
|
-
requireFnFromTemplate =
|
|
2552
|
+
requireFnFromTemplate = (packageOrPath) => {
|
|
2541
2553
|
const isPath = packageOrPath.startsWith("./") || packageOrPath.startsWith("../");
|
|
2542
|
-
if (isPath) return
|
|
2543
|
-
return
|
|
2554
|
+
if (isPath) return require$1(node_path.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
|
|
2555
|
+
return require$1(packageOrPath);
|
|
2544
2556
|
};
|
|
2545
2557
|
getTemplate = (name$1, fileName, path$1) => {
|
|
2546
2558
|
const { templatePaths } = this.config;
|
|
@@ -2658,7 +2670,7 @@ var JavascriptTranslator = class extends Translator {
|
|
|
2658
2670
|
//#endregion
|
|
2659
2671
|
//#region src/type-name-formatter.ts
|
|
2660
2672
|
var TypeNameFormatter = class {
|
|
2661
|
-
formattedModelNamesMap = new Map();
|
|
2673
|
+
formattedModelNamesMap = /* @__PURE__ */ new Map();
|
|
2662
2674
|
config;
|
|
2663
2675
|
constructor(config) {
|
|
2664
2676
|
this.config = config;
|
|
@@ -3236,4 +3248,4 @@ Object.defineProperty(exports, 'package_default', {
|
|
|
3236
3248
|
return package_default;
|
|
3237
3249
|
}
|
|
3238
3250
|
});
|
|
3239
|
-
//# sourceMappingURL=src-
|
|
3251
|
+
//# sourceMappingURL=src-B-cU8h_Y.cjs.map
|