swagger-typescript-api 12.0.0 → 12.0.1

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
@@ -151,7 +151,10 @@ interface GenerateApiParamsBase {
151
151
  typePrefix?: string;
152
152
  /** suffix string value for type names */
153
153
  typeSuffix?: string;
154
+ /** extra configuration for extracting type names operations */
154
155
  extractingOptions?: Partial<ExtractingOptions>;
156
+ /** configuration for fetching swagger schema requests */
157
+ requestOptions?: null | Partial<import("node-fetch").RequestInit>;
155
158
  }
156
159
 
157
160
  type CodeGenConstruct = {
@@ -529,6 +532,7 @@ export interface GenerateApiConfiguration {
529
532
  routes: ParsedRoute[];
530
533
  }[];
531
534
  };
535
+ requestOptions?: null | Partial<import("node-fetch").RequestInit>;
532
536
  utils: {
533
537
  formatDescription: (description: string, inline?: boolean) => string;
534
538
  internalCase: (value: string) => string;
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.1",
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);