@penkov/swagger-code-gen 1.7.6 → 1.7.7
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/property.js +1 -0
- package/dist/templates/index.ejs +2 -0
- package/dist/templates/method.ejs +20 -12
- package/package.json +1 -1
package/dist/property.js
CHANGED
package/dist/templates/index.ejs
CHANGED
|
@@ -62,6 +62,7 @@ export async function <%= method.endpointName %><%= body.map(b => b.suffix).getO
|
|
|
62
62
|
query = '?' + queryParams.join('&');
|
|
63
63
|
}
|
|
64
64
|
<%_ } -%>
|
|
65
|
+
|
|
65
66
|
let bodySerialised: BodyInit | null = null;
|
|
66
67
|
<%_ if (body.nonEmpty && body.get.mimeType === 'application/json') {%>
|
|
67
68
|
bodySerialised = JSON.stringify(body);
|
|
@@ -72,22 +73,29 @@ export async function <%= method.endpointName %><%= body.map(b => b.suffix).getO
|
|
|
72
73
|
<%_ } else if (body.nonEmpty && body.get.mimeType === 'application/octet-stream') { -%>
|
|
73
74
|
bodySerialised = body;
|
|
74
75
|
<%_ } -%>
|
|
76
|
+
|
|
77
|
+
const headers: HeadersInit = {
|
|
78
|
+
...requestOptions.headers || {},
|
|
79
|
+
'Accept': 'application/json',
|
|
80
|
+
<%_ if (body.nonEmpty && body.get.mimeType !== 'multipart/form-data') {%>
|
|
81
|
+
'Content-Type': '<%= body.get.mimeType %>',
|
|
82
|
+
<%_ } -%>
|
|
83
|
+
<%_ if (method.parameters.filter(x => x.in === 'header').nonEmpty) { -%>
|
|
84
|
+
<%_ method.parameters.filter(x => x.in === 'header').foreach(p => { -%>
|
|
85
|
+
<%= p.name %>: <%= method.wrapParamsInObject ? 'params.' : '' %><%= p.uniqueName %>,
|
|
86
|
+
<%_ }) -%>
|
|
87
|
+
<%_ } -%>
|
|
88
|
+
};
|
|
89
|
+
<%_ if (body.nonEmpty && body.get.mimeType === 'multipart/form-data') {%>
|
|
90
|
+
delete headers['Content-Type'];
|
|
91
|
+
<%_ } -%>
|
|
92
|
+
|
|
93
|
+
|
|
75
94
|
const request = new Request(`${requestOptions.apiPrefix}<%- method.pathWithSubstitutions %>${query}`, {
|
|
76
95
|
method: '<%= method.method %>',
|
|
77
96
|
body: bodySerialised,
|
|
78
97
|
signal: requestOptions.signal,
|
|
79
|
-
headers:
|
|
80
|
-
...requestOptions.headers || {},
|
|
81
|
-
'Accept': 'application/json',
|
|
82
|
-
<%_ if (body.nonEmpty && body.get.mimeType !== 'multipart/form-data') {%>
|
|
83
|
-
'Content-Type': '<%= body.get.mimeType %>',
|
|
84
|
-
<%_ } -%>
|
|
85
|
-
<%_ if (method.parameters.filter(x => x.in === 'header').nonEmpty) { -%>
|
|
86
|
-
<%_ method.parameters.filter(x => x.in === 'header').foreach(p => { -%>
|
|
87
|
-
<%= p.name %>: <%= method.wrapParamsInObject ? 'params.' : '' %><%= p.uniqueName %>,
|
|
88
|
-
<%_ }) -%>
|
|
89
|
-
<%_ } -%>
|
|
90
|
-
}
|
|
98
|
+
headers: headers
|
|
91
99
|
});
|
|
92
100
|
return requestImpl<<%- method.response.responseType %>>(request, requestOptions);
|
|
93
101
|
}
|