swagger-typescript-api 12.0.0 → 12.0.2

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/index.d.ts CHANGED
@@ -54,6 +54,11 @@ interface GenerateApiParamsBase {
54
54
  */
55
55
  unwrapResponseData?: boolean;
56
56
 
57
+ /**
58
+ * sort data contracts in alphabetical order
59
+ */
60
+ sortTypes?: boolean;
61
+
57
62
  /**
58
63
  * generate js api module with declaration file (default: false)
59
64
  */
@@ -151,7 +156,10 @@ interface GenerateApiParamsBase {
151
156
  typePrefix?: string;
152
157
  /** suffix string value for type names */
153
158
  typeSuffix?: string;
159
+ /** extra configuration for extracting type names operations */
154
160
  extractingOptions?: Partial<ExtractingOptions>;
161
+ /** configuration for fetching swagger schema requests */
162
+ requestOptions?: null | Partial<import("node-fetch").RequestInit>;
155
163
  }
156
164
 
157
165
  type CodeGenConstruct = {
@@ -529,6 +537,7 @@ export interface GenerateApiConfiguration {
529
537
  routes: ParsedRoute[];
530
538
  }[];
531
539
  };
540
+ requestOptions?: null | Partial<import("node-fetch").RequestInit>;
532
541
  utils: {
533
542
  formatDescription: (description: string, inline?: boolean) => string;
534
543
  internalCase: (value: string) => string;
package/index.js CHANGED
@@ -292,6 +292,7 @@ const main = async () => {
292
292
  apiClassName: options.apiClassName,
293
293
  debug: options.debug,
294
294
  anotherArrayType: options.anotherArrayType,
295
+ extractEnums: options.extractEnums,
295
296
  });
296
297
  break;
297
298
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-typescript-api",
3
- "version": "12.0.0",
3
+ "version": "12.0.2",
4
4
  "description": "Generate typescript/javascript api from swagger schema",
5
5
  "scripts": {
6
6
  "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",
@@ -1,3 +1,4 @@
1
+ const _ = require("lodash");
1
2
  const https = require("https");
2
3
  const fetch = require("node-fetch-h2");
3
4
 
@@ -18,7 +19,7 @@ class Request {
18
19
 
19
20
  /**
20
21
  *
21
- * @param url
22
+ * @param url {string}
22
23
  * @param disableStrictSSL
23
24
  * @param authToken
24
25
  * @param options {Partial<import("node-fetch").RequestInit>}
@@ -28,11 +29,9 @@ class Request {
28
29
  /**
29
30
  * @type {Partial<import("node-fetch").RequestInit>}
30
31
  */
31
- const requestOptions = {
32
- ...(this.config.requestOptions || {}),
33
- };
32
+ const requestOptions = {};
34
33
 
35
- if (disableStrictSSL) {
34
+ if (disableStrictSSL && !_.startsWith(url, "http://")) {
36
35
  requestOptions.agent = new https.Agent({
37
36
  rejectUnauthorized: false,
38
37
  });
@@ -43,7 +42,7 @@ class Request {
43
42
  };
44
43
  }
45
44
 
46
- Object.assign(requestOptions, options);
45
+ _.merge(requestOptions, options, this.config.requestOptions);
47
46
 
48
47
  try {
49
48
  const response = await fetch(url, requestOptions);