Skip to content

Commit 1ce2dd5

Browse files
authored
Merge pull request #454 from acacode/next
Release 12.0.1
2 parents e3e0e6e + 27ed813 commit 1ce2dd5

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# next release
1+
# next release
2+
3+
## 12.0.1
4+
5+
fix: problem based with http requests and `disableStrictSSL` option (#453)
6+
docs: update docs for `requestOptions` nodejs option
27

38
## 12.0.0
49

index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ interface GenerateApiParamsBase {
151151
typePrefix?: string;
152152
/** suffix string value for type names */
153153
typeSuffix?: string;
154+
/** extra configuration for extracting type names operations */
154155
extractingOptions?: Partial<ExtractingOptions>;
156+
/** configuration for fetching swagger schema requests */
157+
requestOptions?: null | Partial<import("node-fetch").RequestInit>;
155158
}
156159

157160
type CodeGenConstruct = {
@@ -529,6 +532,7 @@ export interface GenerateApiConfiguration {
529532
routes: ParsedRoute[];
530533
}[];
531534
};
535+
requestOptions?: null | Partial<import("node-fetch").RequestInit>;
532536
utils: {
533537
formatDescription: (description: string, inline?: boolean) => string;
534538
internalCase: (value: string) => string;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swagger-typescript-api",
3-
"version": "12.0.0",
3+
"version": "12.0.1",
44
"description": "Generate typescript/javascript api from swagger schema",
55
"scripts": {
66
"cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",

src/util/request.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const _ = require("lodash");
12
const https = require("https");
23
const fetch = require("node-fetch-h2");
34

@@ -18,7 +19,7 @@ class Request {
1819

1920
/**
2021
*
21-
* @param url
22+
* @param url {string}
2223
* @param disableStrictSSL
2324
* @param authToken
2425
* @param options {Partial<import("node-fetch").RequestInit>}
@@ -28,11 +29,9 @@ class Request {
2829
/**
2930
* @type {Partial<import("node-fetch").RequestInit>}
3031
*/
31-
const requestOptions = {
32-
...(this.config.requestOptions || {}),
33-
};
32+
const requestOptions = {};
3433

35-
if (disableStrictSSL) {
34+
if (disableStrictSSL && !_.startsWith(url, "http://")) {
3635
requestOptions.agent = new https.Agent({
3736
rejectUnauthorized: false,
3837
});
@@ -43,7 +42,7 @@ class Request {
4342
};
4443
}
4544

46-
Object.assign(requestOptions, options);
45+
_.merge(requestOptions, options, this.config.requestOptions);
4746

4847
try {
4948
const response = await fetch(url, requestOptions);

0 commit comments

Comments
 (0)