ng-openapi 0.2.16 → 0.2.17
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/cli.cjs +4 -10
- package/index.js +3 -9
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -44,7 +44,7 @@ var fs4 = __toESM(require("fs"));
|
|
|
44
44
|
var path12 = __toESM(require("path"));
|
|
45
45
|
|
|
46
46
|
// package.json
|
|
47
|
-
var version = "0.2.
|
|
47
|
+
var version = "0.2.16";
|
|
48
48
|
|
|
49
49
|
// src/lib/core/generator.ts
|
|
50
50
|
var import_ts_morph7 = require("ts-morph");
|
|
@@ -2101,15 +2101,12 @@ ${paramMappings}`;
|
|
|
2101
2101
|
}
|
|
2102
2102
|
generateHeaders(context) {
|
|
2103
2103
|
const hasCustomHeaders = this.config.options.customHeaders;
|
|
2104
|
-
if (!hasCustomHeaders && !context.isMultipart && !context.isUrlEncoded) {
|
|
2105
|
-
return "";
|
|
2106
|
-
}
|
|
2107
2104
|
let headerCode = `
|
|
2108
2105
|
let headers: HttpHeaders;
|
|
2109
2106
|
if (options?.headers instanceof HttpHeaders) {
|
|
2110
2107
|
headers = options.headers;
|
|
2111
2108
|
} else {
|
|
2112
|
-
headers = new HttpHeaders(
|
|
2109
|
+
headers = new HttpHeaders(requestOptions?.headers);
|
|
2113
2110
|
}`;
|
|
2114
2111
|
if (hasCustomHeaders) {
|
|
2115
2112
|
headerCode += `
|
|
@@ -2128,7 +2125,7 @@ headers = headers.delete('Content-Type');`;
|
|
|
2128
2125
|
if (!headers.has('Content-Type')) {
|
|
2129
2126
|
headers = headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
|
2130
2127
|
}`;
|
|
2131
|
-
} else {
|
|
2128
|
+
} else if (context.hasBody) {
|
|
2132
2129
|
headerCode += `
|
|
2133
2130
|
// Set Content-Type for JSON requests if not already set
|
|
2134
2131
|
if (!headers.has('Content-Type')) {
|
|
@@ -2207,10 +2204,7 @@ ${formBodyAppends}`;
|
|
|
2207
2204
|
generateRequestOptions(context) {
|
|
2208
2205
|
const options = [];
|
|
2209
2206
|
options.push("observe: observe as any");
|
|
2210
|
-
|
|
2211
|
-
if (hasHeaders) {
|
|
2212
|
-
options.push("headers");
|
|
2213
|
-
}
|
|
2207
|
+
options.push("headers");
|
|
2214
2208
|
if (context.queryParams.length > 0) {
|
|
2215
2209
|
options.push("params");
|
|
2216
2210
|
}
|
package/index.js
CHANGED
|
@@ -2227,15 +2227,12 @@ ${paramMappings}`;
|
|
|
2227
2227
|
}
|
|
2228
2228
|
generateHeaders(context) {
|
|
2229
2229
|
const hasCustomHeaders = this.config.options.customHeaders;
|
|
2230
|
-
if (!hasCustomHeaders && !context.isMultipart && !context.isUrlEncoded) {
|
|
2231
|
-
return "";
|
|
2232
|
-
}
|
|
2233
2230
|
let headerCode = `
|
|
2234
2231
|
let headers: HttpHeaders;
|
|
2235
2232
|
if (options?.headers instanceof HttpHeaders) {
|
|
2236
2233
|
headers = options.headers;
|
|
2237
2234
|
} else {
|
|
2238
|
-
headers = new HttpHeaders(
|
|
2235
|
+
headers = new HttpHeaders(requestOptions?.headers);
|
|
2239
2236
|
}`;
|
|
2240
2237
|
if (hasCustomHeaders) {
|
|
2241
2238
|
headerCode += `
|
|
@@ -2254,7 +2251,7 @@ headers = headers.delete('Content-Type');`;
|
|
|
2254
2251
|
if (!headers.has('Content-Type')) {
|
|
2255
2252
|
headers = headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
|
2256
2253
|
}`;
|
|
2257
|
-
} else {
|
|
2254
|
+
} else if (context.hasBody) {
|
|
2258
2255
|
headerCode += `
|
|
2259
2256
|
// Set Content-Type for JSON requests if not already set
|
|
2260
2257
|
if (!headers.has('Content-Type')) {
|
|
@@ -2335,10 +2332,7 @@ ${formBodyAppends}`;
|
|
|
2335
2332
|
generateRequestOptions(context) {
|
|
2336
2333
|
const options = [];
|
|
2337
2334
|
options.push("observe: observe as any");
|
|
2338
|
-
|
|
2339
|
-
if (hasHeaders) {
|
|
2340
|
-
options.push("headers");
|
|
2341
|
-
}
|
|
2335
|
+
options.push("headers");
|
|
2342
2336
|
if (context.queryParams.length > 0) {
|
|
2343
2337
|
options.push("params");
|
|
2344
2338
|
}
|