@@ -50,7 +50,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
50
50
{%~ endif %}
51
51
*/
52
52
{%~ if method .parameters .all | length > 0 %}
53
- {% if method .type == ' upload' %}async {% endif %}{{ method .name | caseCamel }}{{ method .responseModel | getGenerics(spec ) | raw }}(params: { {% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %} {% if ' multipart/form-data' in method .consumes %}, onProgress?: (progress: UploadProgress) => {} {% endif %} }): {{ method | getReturn(spec ) | raw }};
53
+ {% if method .type == ' upload' %}async {% endif %}{{ method .name | caseCamel }}{{ method .responseModel | getGenerics(spec ) | raw }}(params? : { {% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %} {% if ' multipart/form-data' in method .consumes %}, onProgress?: (progress: UploadProgress) => void {% endif %} }): {{ method | getReturn(spec ) | raw }};
54
54
/**
55
55
{%~ if method .description %}
56
56
* {{ method .description | replace({' \n' : ' \n * ' }) | raw }}
@@ -63,22 +63,22 @@ export class {{ service.name | caseUcfirst }} extends Service {
63
63
* @returns {{ ' {' }}{{ method | getReturn(spec ) | raw }}{{ ' }' }}
64
64
* @deprecated Use the object parameter style method for a better developer experience.
65
65
*/
66
- {% if method .type == ' upload' %}async {% endif %}{{ method .name | caseCamel }}{{ method .responseModel | getGenerics(spec ) | raw }}({% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %}, onProgress?: (progress: UploadProgress) => {} {% endif %}): {{ method | getReturn(spec ) | raw }};
66
+ {% if method .type == ' upload' %}async {% endif %}{{ method .name | caseCamel }}{{ method .responseModel | getGenerics(spec ) | raw }}({% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %}, onProgress?: (progress: UploadProgress) => void {% endif %}): {{ method | getReturn(spec ) | raw }};
67
67
{% if method .type == ' upload' %}async {% endif %}{{ method .name | caseCamel }}{{ method .responseModel | getGenerics(spec ) | raw }}(
68
- {% if method .parameters .all | length > 0 %}paramsOrFirst{% if not method .parameters .all [0 ].required or method .parameters .all [0 ].nullable %}?{% endif %}: { {% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %}, onProgress?: (progress: UploadProgress) => {} {% endif %} } | {{ method .parameters .all [0 ] | getPropertyType(method ) | raw }}{% if method .parameters .all | length > 1 %},
69
- ...rest: [{% for parameter in method .parameters .all [1:] %}({{ parameter | getPropertyType(method ) | raw }})?{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %},((progress: UploadProgress) => {} )?{% endif %}]{% endif %}{% endif %}
68
+ {% if method .parameters .all | length > 0 %}paramsOrFirst{% if not method .parameters .all [0 ].required or method .parameters .all [0 ].nullable %}?{% endif %}: { {% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %}, onProgress?: (progress: UploadProgress) => void {% endif %} } | {{ method .parameters .all [0 ] | getPropertyType(method ) | raw }}{% if method .parameters .all | length > 1 %},
69
+ ...rest: [{% for parameter in method .parameters .all [1:] %}({{ parameter | getPropertyType(method ) | raw }})?{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %},((progress: UploadProgress) => void )?{% endif %}]{% endif %}{% endif %}
70
70
71
71
): {{ method | getReturn(spec ) | raw }} {
72
72
{%~ if method .parameters .all | length > 0 %}
73
73
let params: { {% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %} };
74
74
{%~ if ' multipart/form-data' in method .consumes %}
75
- let onProgress: ((progress: UploadProgress) => {} );
75
+ let onProgress: ((progress: UploadProgress) => void );
76
76
{%~ endif %}
77
77
78
78
if ({% set hasRequired = false %}{% for parameter in method .parameters .all %}{% if parameter .required %}{% set hasRequired = true %}{% endif %}{% endfor %}{% if not hasRequired %}!paramsOrFirst || {% endif %}(paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst){% set firstParamType = method .parameters .all [0 ] | getPropertyType(method ) | raw %}{% if not (firstParamType starts with ' string' or firstParamType starts with ' number' or firstParamType starts with ' boolean' ) %} && '{{ method .parameters .all [0 ].name | caseCamel | escapeKeyword }}' in paramsOrFirst{% endif %})) {
79
79
params = (paramsOrFirst || {}) as { {% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %} };
80
80
{%~ if ' multipart/form-data' in method .consumes %}
81
- onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => {} );
81
+ onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void );
82
82
{%~ endif %}
83
83
} else {
84
84
params = {
@@ -89,7 +89,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
89
89
90
90
};
91
91
{%~ if ' multipart/form-data' in method .consumes %}
92
- onProgress = rest[{{ method .parameters .all | length - 1 }}] as ((progress: UploadProgress) => {} );
92
+ onProgress = rest[{{ method .parameters .all | length - 1 }}] as ((progress: UploadProgress) => void );
93
93
{%~ endif %}
94
94
}
95
95
@@ -105,7 +105,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
105
105
{%~ endif %}
106
106
{%~ endif %}
107
107
{%~ else %}
108
- {{ method .name | caseCamel }}{{ method .responseModel | getGenerics(spec ) | raw }}({% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %}, onProgress = (progress: UploadProgress) => {} {% endif %}): {{ method | getReturn(spec ) | raw }} {
108
+ {{ method .name | caseCamel }}{{ method .responseModel | getGenerics(spec ) | raw }}({% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %}, onProgress = (progress: UploadProgress) => void {% endif %}): {{ method | getReturn(spec ) | raw }} {
109
109
{%~ endif %}
110
110
{% for parameter in method .parameters .all %}
111
111
{% if parameter .required %}
@@ -262,7 +262,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
262
262
* @deprecated This API has been deprecated since {{ method .since }}. Please use `{{ method .replaceWith | capitalizeFirst }}` instead.
263
263
{%~ endif %}
264
264
*/
265
- {{ method .name | caseCamel }}URL({% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %}, onProgress = (progress: UploadProgress) => {} {% endif %}): URL {
265
+ {{ method .name | caseCamel }}URL({% for parameter in method .parameters .all %}{{ parameter .name | caseCamel | escapeKeyword }}{% if not parameter .required or parameter .nullable %}?{% endif %}: {{ parameter | getPropertyType(method ) | raw }}{% if not loop .last %}, {% endif %}{% endfor %}{% if ' multipart/form-data' in method .consumes %}, onProgress = (progress: UploadProgress) => void {% endif %}): URL {
266
266
const apiPath = '{{ method .path }}'{% for parameter in method .parameters .path %}.replace('{{ ' {' }}{{ parameter .name | caseCamel | escapeKeyword }}{{ ' }' }}', {{ parameter .name | caseCamel | escapeKeyword }}){% endfor %};
267
267
const payload: Payload = {};
268
268
0 commit comments