@penkov/swagger-code-gen 1.0.7 → 1.0.8
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/templates/index.ejs +15 -10
- package/dist/templates/method.ejs +1 -1
- package/package.json +1 -1
package/dist/templates/index.ejs
CHANGED
|
@@ -12,28 +12,33 @@
|
|
|
12
12
|
*********************************************************/
|
|
13
13
|
import fetch from 'node-fetch';
|
|
14
14
|
|
|
15
|
+
export interface RequestOptions {
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
15
20
|
export interface SwaggerCodeGenParams {
|
|
16
21
|
apiPrefix: string;
|
|
22
|
+
requestOptions: RequestOptions
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
export const swaggerCodeGenParams: SwaggerCodeGenParams = {
|
|
20
|
-
apiPrefix: ''
|
|
26
|
+
apiPrefix: '',
|
|
27
|
+
requestOptions: {
|
|
28
|
+
headers: {
|
|
29
|
+
'Accept': 'application/json',
|
|
30
|
+
'Content-Type': 'application/json'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
21
33
|
};
|
|
22
34
|
|
|
35
|
+
const defaultRequestOptions = () => swaggerCodeGenParams.requestOptions;
|
|
36
|
+
|
|
23
37
|
<% schemas.foreach(schema => { %>
|
|
24
38
|
<%- include('schema.ejs', {schema: schema}); %>
|
|
25
39
|
<% }); %>
|
|
26
40
|
|
|
27
|
-
export interface RequestOptions {
|
|
28
|
-
headers: Record<string, string>;
|
|
29
|
-
}
|
|
30
41
|
|
|
31
|
-
export const defaultRequestOptions = {
|
|
32
|
-
headers: {
|
|
33
|
-
'Accept': 'application/json',
|
|
34
|
-
'Content-Type': 'application/json'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
42
|
|
|
38
43
|
<% methods.foreach(method => { %>
|
|
39
44
|
<%- include('method.ejs', {method: method}); %>
|
|
@@ -28,7 +28,7 @@ export async function <%= method.endpointName %>(
|
|
|
28
28
|
<%_ if (method.body.nonEmpty) { -%>
|
|
29
29
|
body: <%= method.body.get.type %>,
|
|
30
30
|
<%_ } -%>
|
|
31
|
-
requestOptions: RequestOptions = defaultRequestOptions
|
|
31
|
+
requestOptions: RequestOptions = defaultRequestOptions()
|
|
32
32
|
): Promise<<%= method.response.responseType %>> {
|
|
33
33
|
let query = '';
|
|
34
34
|
<%_ if (method.parameters.filter(x => x.in === 'query').nonEmpty) { -%>
|