swagger-typescript-api 13.0.13 → 13.0.15

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/types.d.cts CHANGED
@@ -1216,7 +1216,7 @@ interface GenerateApiParamsBase {
1216
1216
  requestOptions?: null | Partial<RequestInit>;
1217
1217
 
1218
1218
  /** ts compiler configuration object (for --to-js option) */
1219
- compilerTsConfig?: Record<string, any>;
1219
+ compilerTsConfig?: Record<string, unknown>;
1220
1220
 
1221
1221
  /**
1222
1222
  * custom ts->* translator
@@ -1289,28 +1289,28 @@ type CodeGenConstruct = {
1289
1289
  CodeGenKeyword: {
1290
1290
  UtilRequiredKeys: string;
1291
1291
  };
1292
- ArrayType: (content: any) => string;
1293
- StringValue: (content: any) => string;
1294
- BooleanValue: (content: any) => string;
1295
- NumberValue: (content: any) => string;
1296
- NullValue: (content: any) => string;
1297
- UnionType: (content: any) => string;
1298
- ExpressionGroup: (content: any) => string;
1299
- IntersectionType: (content: any) => string;
1300
- RecordType: (content: any) => string;
1301
- TypeField: (content: any) => string;
1302
- InterfaceDynamicField: (content: any) => string;
1303
- EnumField: (content: any) => string;
1304
- EnumFieldsWrapper: (content: any) => string;
1305
- ObjectWrapper: (content: any) => string;
1306
- MultilineComment: (content: any) => string;
1307
- TypeWithGeneric: (content: any) => string;
1292
+ ArrayType: (content: unknown) => string;
1293
+ StringValue: (content: unknown) => string;
1294
+ BooleanValue: (content: unknown) => string;
1295
+ NumberValue: (content: unknown) => string;
1296
+ NullValue: (content: unknown) => string;
1297
+ UnionType: (content: unknown) => string;
1298
+ ExpressionGroup: (content: unknown) => string;
1299
+ IntersectionType: (content: unknown) => string;
1300
+ RecordType: (content: unknown) => string;
1301
+ TypeField: (content: unknown) => string;
1302
+ InterfaceDynamicField: (content: unknown) => string;
1303
+ EnumField: (content: unknown) => string;
1304
+ EnumFieldsWrapper: (content: unknown) => string;
1305
+ ObjectWrapper: (content: unknown) => string;
1306
+ MultilineComment: (content: unknown) => string;
1307
+ TypeWithGeneric: (content: unknown) => string;
1308
1308
  };
1309
1309
 
1310
1310
  type PrimitiveTypeStructValue =
1311
1311
  | string
1312
1312
  | ((
1313
- schema: Record<string, any>,
1313
+ schema: Record<string, unknown>,
1314
1314
  parser: SchemaParser,
1315
1315
  ) => string);
1316
1316
 
@@ -1373,60 +1373,65 @@ type BuildRoutePath = {
1373
1373
 
1374
1374
  interface Hooks {
1375
1375
  /** calls before parse\process route path */
1376
- onPreBuildRoutePath: (routePath: string) => string | void;
1376
+ onPreBuildRoutePath: (routePath: string) => string | undefined;
1377
1377
  /** calls after parse\process route path */
1378
- onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | void;
1378
+ onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | undefined;
1379
1379
  /** calls before insert path param name into string path interpolation */
1380
1380
  onInsertPathParam: (
1381
1381
  paramName: string,
1382
1382
  index: number,
1383
1383
  arr: BuildRouteParam[],
1384
1384
  resultRoute: string,
1385
- ) => string | void;
1385
+ ) => string | undefined;
1386
1386
  /** calls after parse schema component */
1387
- onCreateComponent: (component: SchemaComponent) => SchemaComponent | void;
1387
+ onCreateComponent: (
1388
+ component: SchemaComponent,
1389
+ ) => SchemaComponent | undefined;
1388
1390
  /** calls before parse any kind of schema */
1389
1391
  onPreParseSchema: (
1390
- originalSchema: any,
1392
+ originalSchema: unknown,
1391
1393
  typeName: string,
1392
1394
  schemaType: string,
1393
- ) => any;
1395
+ ) => undefined;
1394
1396
  /** calls after parse any kind of schema */
1395
- onParseSchema: (originalSchema: any, parsedSchema: any) => any | void;
1397
+ onParseSchema: (
1398
+ originalSchema: unknown,
1399
+ parsedSchema: unknown,
1400
+ ) => unknown | undefined;
1396
1401
  /** calls after parse route (return type: customized route (ParsedRoute), nothing change (void), false (ignore this route)) */
1397
- onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | void | false;
1402
+ onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | false | undefined;
1398
1403
  /** Start point of work this tool (after fetching schema) */
1399
1404
  onInit?: <C extends GenerateApiConfiguration["config"]>(
1400
1405
  configuration: C,
1401
1406
  codeGenProcess: CodeGenProcess,
1402
- ) => C | void;
1407
+ ) => C | undefined;
1403
1408
  /** customize configuration object before sending it to ETA templates */
1404
1409
  onPrepareConfig?: <C extends GenerateApiConfiguration>(
1405
1410
  currentConfiguration: C,
1406
- ) => C | void;
1411
+ ) => C | undefined;
1407
1412
  /** customize route name as you need */
1408
1413
  onCreateRouteName?: (
1409
1414
  routeNameInfo: RouteNameInfo,
1410
1415
  rawRouteInfo: RawRouteInfo,
1411
- ) => RouteNameInfo | void;
1416
+ ) => RouteNameInfo | undefined;
1412
1417
  /** customize request params (path params, query params) */
1413
1418
  onCreateRequestParams?: (
1414
1419
  rawType: SchemaComponent["rawTypeData"],
1415
- ) => SchemaComponent["rawTypeData"] | void;
1420
+ ) => SchemaComponent["rawTypeData"] | undefined;
1416
1421
  /** customize name of model type */
1417
1422
  onFormatTypeName?: (
1418
1423
  typeName: string,
1419
1424
  rawTypeName?: string,
1420
1425
  schemaType?: "type-name" | "enum-key",
1421
- ) => string | void;
1426
+ ) => string | undefined;
1422
1427
  /** customize name of route (operationId), you can do it with using onCreateRouteName too */
1423
1428
  onFormatRouteName?: (
1424
1429
  routeInfo: RawRouteInfo,
1425
1430
  templateRouteName: string,
1426
- ) => string | void;
1431
+ ) => string | undefined;
1427
1432
  }
1428
1433
 
1429
- type RouteNameRouteInfo = {};
1434
+ type RouteNameRouteInfo = Record<unknown, unknown>;
1430
1435
 
1431
1436
  type RouteNameInfo = {
1432
1437
  usage: string;
@@ -1439,7 +1444,7 @@ type SchemaTypePrimitiveContent = {
1439
1444
  schemaType: string;
1440
1445
  type: string;
1441
1446
  typeIdentifier: string;
1442
- name?: any;
1447
+ name?: unknown;
1443
1448
  description: string;
1444
1449
  content: string;
1445
1450
  };
@@ -1625,7 +1630,7 @@ interface GenerateApiConfiguration {
1625
1630
  input: string;
1626
1631
  output: string;
1627
1632
  url: string;
1628
- spec: any;
1633
+ spec: unknown;
1629
1634
  fileName: string;
1630
1635
  templatePaths: {
1631
1636
  /** `templates/base` */
@@ -1682,7 +1687,7 @@ interface GenerateApiConfiguration {
1682
1687
  hooks: Hooks;
1683
1688
  enumNamesAsValues: boolean;
1684
1689
  version: string;
1685
- compilerTsConfig: Record<string, any>;
1690
+ compilerTsConfig: Record<string, unknown>;
1686
1691
  enumKeyResolverName: string;
1687
1692
  typeNameResolverName: string;
1688
1693
  specificArgNameResolverName: string;
package/dist/types.d.ts CHANGED
@@ -1216,7 +1216,7 @@ interface GenerateApiParamsBase {
1216
1216
  requestOptions?: null | Partial<RequestInit>;
1217
1217
 
1218
1218
  /** ts compiler configuration object (for --to-js option) */
1219
- compilerTsConfig?: Record<string, any>;
1219
+ compilerTsConfig?: Record<string, unknown>;
1220
1220
 
1221
1221
  /**
1222
1222
  * custom ts->* translator
@@ -1289,28 +1289,28 @@ type CodeGenConstruct = {
1289
1289
  CodeGenKeyword: {
1290
1290
  UtilRequiredKeys: string;
1291
1291
  };
1292
- ArrayType: (content: any) => string;
1293
- StringValue: (content: any) => string;
1294
- BooleanValue: (content: any) => string;
1295
- NumberValue: (content: any) => string;
1296
- NullValue: (content: any) => string;
1297
- UnionType: (content: any) => string;
1298
- ExpressionGroup: (content: any) => string;
1299
- IntersectionType: (content: any) => string;
1300
- RecordType: (content: any) => string;
1301
- TypeField: (content: any) => string;
1302
- InterfaceDynamicField: (content: any) => string;
1303
- EnumField: (content: any) => string;
1304
- EnumFieldsWrapper: (content: any) => string;
1305
- ObjectWrapper: (content: any) => string;
1306
- MultilineComment: (content: any) => string;
1307
- TypeWithGeneric: (content: any) => string;
1292
+ ArrayType: (content: unknown) => string;
1293
+ StringValue: (content: unknown) => string;
1294
+ BooleanValue: (content: unknown) => string;
1295
+ NumberValue: (content: unknown) => string;
1296
+ NullValue: (content: unknown) => string;
1297
+ UnionType: (content: unknown) => string;
1298
+ ExpressionGroup: (content: unknown) => string;
1299
+ IntersectionType: (content: unknown) => string;
1300
+ RecordType: (content: unknown) => string;
1301
+ TypeField: (content: unknown) => string;
1302
+ InterfaceDynamicField: (content: unknown) => string;
1303
+ EnumField: (content: unknown) => string;
1304
+ EnumFieldsWrapper: (content: unknown) => string;
1305
+ ObjectWrapper: (content: unknown) => string;
1306
+ MultilineComment: (content: unknown) => string;
1307
+ TypeWithGeneric: (content: unknown) => string;
1308
1308
  };
1309
1309
 
1310
1310
  type PrimitiveTypeStructValue =
1311
1311
  | string
1312
1312
  | ((
1313
- schema: Record<string, any>,
1313
+ schema: Record<string, unknown>,
1314
1314
  parser: SchemaParser,
1315
1315
  ) => string);
1316
1316
 
@@ -1373,60 +1373,65 @@ type BuildRoutePath = {
1373
1373
 
1374
1374
  interface Hooks {
1375
1375
  /** calls before parse\process route path */
1376
- onPreBuildRoutePath: (routePath: string) => string | void;
1376
+ onPreBuildRoutePath: (routePath: string) => string | undefined;
1377
1377
  /** calls after parse\process route path */
1378
- onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | void;
1378
+ onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | undefined;
1379
1379
  /** calls before insert path param name into string path interpolation */
1380
1380
  onInsertPathParam: (
1381
1381
  paramName: string,
1382
1382
  index: number,
1383
1383
  arr: BuildRouteParam[],
1384
1384
  resultRoute: string,
1385
- ) => string | void;
1385
+ ) => string | undefined;
1386
1386
  /** calls after parse schema component */
1387
- onCreateComponent: (component: SchemaComponent) => SchemaComponent | void;
1387
+ onCreateComponent: (
1388
+ component: SchemaComponent,
1389
+ ) => SchemaComponent | undefined;
1388
1390
  /** calls before parse any kind of schema */
1389
1391
  onPreParseSchema: (
1390
- originalSchema: any,
1392
+ originalSchema: unknown,
1391
1393
  typeName: string,
1392
1394
  schemaType: string,
1393
- ) => any;
1395
+ ) => undefined;
1394
1396
  /** calls after parse any kind of schema */
1395
- onParseSchema: (originalSchema: any, parsedSchema: any) => any | void;
1397
+ onParseSchema: (
1398
+ originalSchema: unknown,
1399
+ parsedSchema: unknown,
1400
+ ) => unknown | undefined;
1396
1401
  /** calls after parse route (return type: customized route (ParsedRoute), nothing change (void), false (ignore this route)) */
1397
- onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | void | false;
1402
+ onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | false | undefined;
1398
1403
  /** Start point of work this tool (after fetching schema) */
1399
1404
  onInit?: <C extends GenerateApiConfiguration["config"]>(
1400
1405
  configuration: C,
1401
1406
  codeGenProcess: CodeGenProcess,
1402
- ) => C | void;
1407
+ ) => C | undefined;
1403
1408
  /** customize configuration object before sending it to ETA templates */
1404
1409
  onPrepareConfig?: <C extends GenerateApiConfiguration>(
1405
1410
  currentConfiguration: C,
1406
- ) => C | void;
1411
+ ) => C | undefined;
1407
1412
  /** customize route name as you need */
1408
1413
  onCreateRouteName?: (
1409
1414
  routeNameInfo: RouteNameInfo,
1410
1415
  rawRouteInfo: RawRouteInfo,
1411
- ) => RouteNameInfo | void;
1416
+ ) => RouteNameInfo | undefined;
1412
1417
  /** customize request params (path params, query params) */
1413
1418
  onCreateRequestParams?: (
1414
1419
  rawType: SchemaComponent["rawTypeData"],
1415
- ) => SchemaComponent["rawTypeData"] | void;
1420
+ ) => SchemaComponent["rawTypeData"] | undefined;
1416
1421
  /** customize name of model type */
1417
1422
  onFormatTypeName?: (
1418
1423
  typeName: string,
1419
1424
  rawTypeName?: string,
1420
1425
  schemaType?: "type-name" | "enum-key",
1421
- ) => string | void;
1426
+ ) => string | undefined;
1422
1427
  /** customize name of route (operationId), you can do it with using onCreateRouteName too */
1423
1428
  onFormatRouteName?: (
1424
1429
  routeInfo: RawRouteInfo,
1425
1430
  templateRouteName: string,
1426
- ) => string | void;
1431
+ ) => string | undefined;
1427
1432
  }
1428
1433
 
1429
- type RouteNameRouteInfo = {};
1434
+ type RouteNameRouteInfo = Record<unknown, unknown>;
1430
1435
 
1431
1436
  type RouteNameInfo = {
1432
1437
  usage: string;
@@ -1439,7 +1444,7 @@ type SchemaTypePrimitiveContent = {
1439
1444
  schemaType: string;
1440
1445
  type: string;
1441
1446
  typeIdentifier: string;
1442
- name?: any;
1447
+ name?: unknown;
1443
1448
  description: string;
1444
1449
  content: string;
1445
1450
  };
@@ -1625,7 +1630,7 @@ interface GenerateApiConfiguration {
1625
1630
  input: string;
1626
1631
  output: string;
1627
1632
  url: string;
1628
- spec: any;
1633
+ spec: unknown;
1629
1634
  fileName: string;
1630
1635
  templatePaths: {
1631
1636
  /** `templates/base` */
@@ -1682,7 +1687,7 @@ interface GenerateApiConfiguration {
1682
1687
  hooks: Hooks;
1683
1688
  enumNamesAsValues: boolean;
1684
1689
  version: string;
1685
- compilerTsConfig: Record<string, any>;
1690
+ compilerTsConfig: Record<string, unknown>;
1686
1691
  enumKeyResolverName: string;
1687
1692
  typeNameResolverName: string;
1688
1693
  specificArgNameResolverName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-typescript-api",
3
- "version": "13.0.13",
3
+ "version": "13.0.15",
4
4
  "description": "Generate the API client for Fetch or Axios from an OpenAPI Specification",
5
5
  "homepage": "https://github.com/acacode/swagger-typescript-api",
6
6
  "bugs": "https://github.com/acacode/swagger-typescript-api/issues",
@@ -34,16 +34,6 @@
34
34
  "dist",
35
35
  "templates"
36
36
  ],
37
- "scripts": {
38
- "build": "tsup",
39
- "ci": "biome ci .",
40
- "cli:help": "node index.js -h",
41
- "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",
42
- "cli:yaml": "node index.js -r -d -p ./swagger-test-cli.yaml -n swagger-test-cli.ts",
43
- "format": "biome format --write .",
44
- "format:check": "biome format .",
45
- "test": "vitest run"
46
- },
47
37
  "dependencies": {
48
38
  "@types/swagger-schema-official": "^2.0.25",
49
39
  "cosmiconfig": "^9.0.0",
@@ -56,7 +46,7 @@
56
46
  "prettier": "~3.3.3",
57
47
  "swagger-schema-official": "2.0.0-bab6bed",
58
48
  "swagger2openapi": "^7.0.8",
59
- "typescript": "~5.5.3"
49
+ "typescript": "~5.5.4"
60
50
  },
61
51
  "devDependencies": {
62
52
  "@biomejs/biome": "1.8.3",
@@ -64,20 +54,30 @@
64
54
  "@tsconfig/strictest": "2.0.5",
65
55
  "@types/didyoumean": "1.2.2",
66
56
  "@types/js-yaml": "4.0.9",
67
- "@types/lodash": "4.17.6",
68
- "@types/node": "20.14.10",
57
+ "@types/lodash": "4.17.7",
58
+ "@types/node": "22.0.2",
69
59
  "@types/swagger2openapi": "7.0.4",
70
60
  "axios": "1.7.2",
71
61
  "shx": "0.3.4",
72
- "tsup": "8.1.0",
73
- "vitest": "2.0.3"
62
+ "tsup": "8.2.3",
63
+ "vitest": "2.0.5"
74
64
  },
75
- "packageManager": "yarn@4.3.1",
76
65
  "engines": {
77
66
  "node": ">=18.0.0"
78
67
  },
79
68
  "publishConfig": {
80
69
  "access": "public",
70
+ "provenance": true,
81
71
  "registry": "https://registry.npmjs.org"
72
+ },
73
+ "scripts": {
74
+ "build": "tsup",
75
+ "cli:help": "node index.js -h",
76
+ "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",
77
+ "cli:yaml": "node index.js -r -d -p ./swagger-test-cli.yaml -n swagger-test-cli.ts",
78
+ "format": "biome format --write .",
79
+ "format:check": "biome format .",
80
+ "lint": "biome check",
81
+ "test": "vitest run"
82
82
  }
83
83
  }
@@ -127,7 +127,7 @@ export class HttpClient<SecurityDataType = unknown> {
127
127
  ...requestParams,
128
128
  headers: {
129
129
  ...(requestParams.headers || {}),
130
- ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}),
130
+ ...(type ? { "Content-Type": type } : {}),
131
131
  },
132
132
  params: query,
133
133
  responseType: responseFormat,