@@ -21,111 +21,105 @@ import java.util.Map;
21
21
import java.util.HashMap;
22
22
23
23
{ {#operations} }
24
- public class { {classname} } {
25
- private ApiClient apiClient;
24
+ public class { {classname} } {
25
+ private ApiClient apiClient;
26
26
27
- public {{classname} }() {
27
+ public {{classname} }() {
28
28
this(Configuration.getDefaultApiClient());
29
- }
29
+ }
30
30
31
- public { {classname} }(ApiClient apiClient) {
31
+ public { {classname} }(ApiClient apiClient) {
32
32
this.apiClient = apiClient;
33
- }
33
+ }
34
34
35
- public ApiClient getApiClient() {
35
+ public ApiClient getApiClient() {
36
36
return apiClient;
37
- }
37
+ }
38
38
39
- public void setApiClient(ApiClient apiClient) {
39
+ public void setApiClient(ApiClient apiClient) {
40
40
this.apiClient = apiClient;
41
+ }
42
+
43
+ { {#operation} }
44
+ /**
45
+ * { {summary} }
46
+ * { {notes} }
47
+ { {#allParams} } * @param { {paramName} } { {description} }
48
+ { {/allParams} } * @return { {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }void{ {/returnType} }
49
+ */
50
+ public { {#returnType} }{ {{returnType} }} { {/returnType} }{ {^returnType} }void { {/returnType} }{ {nickname} } ({ {#allParams} }{ {{dataType} }} { {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/allParams} }) throws ApiException {
51
+ Object postBody = {{#bodyParam} }{ {paramName} }{ {/bodyParam} }{ {^bodyParam} }null{ {/bodyParam} };
52
+ { {#allParams} }{ {#required} }
53
+ // verify the required parameter '{ {paramName} }' is set
54
+ if ({ {paramName} } == null) {
55
+ throw new ApiException(400, " Missing the required parameter '{{paramName}}' when calling {{nickname}}" );
41
56
}
42
-
43
- { {#operation} }
44
- /**
45
- * { {summary} }
46
- * { {notes} }
47
- { {#allParams} } * @param { {paramName} } { {description} }
48
- { {/allParams} } * @return { {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }void{ {/returnType} }
49
- */
50
- public { {#returnType} }{ {{returnType} }} { {/returnType} }{ {^returnType} }void { {/returnType} }{ {nickname} } ({ {#allParams} }{ {{dataType} }} { {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/allParams} }) throws ApiException {
51
- Object postBody = {{#bodyParam} }{ {paramName} }{ {/bodyParam} }{ {^bodyParam} }null{ {/bodyParam} };
52
- { {#allParams} }{ {#required} }
53
- // verify the required parameter '{ {paramName} }' is set
54
- if ({ {paramName} } == null) {
55
- throw new ApiException(400, " Missing the required parameter '{{paramName}}' when calling {{nickname}}" );
56
- }
57
- { {/required} }{ {/allParams} }
58
-
59
- // create path and map variables
60
- String path = "{ {path} }".replaceAll("\\{ format\\} ","json"){ {#pathParams} }
61
- .replaceAll("\\{ " + " {{paramName} }" + "\\}", apiClient.escapeString({ {{paramName} }}.toString())){ {/pathParams} };
62
-
63
- // query params
64
- Map
65
- <String , String > queryParams = new HashMap
66
- <String , String >();
67
- Map
68
- <String , String > headerParams = new HashMap
69
- <String , String >();
70
- Map
71
- <String , String > formParams = new HashMap
72
- <String , String >();
73
-
74
- { {#queryParams} }if ({ {paramName} } != null)
75
- queryParams.put("{ {baseName} }", apiClient.parameterToString({ {paramName} }));
76
- { {/queryParams} }
77
-
78
- { {#headerParams} }if ({ {paramName} } != null)
79
- headerParams.put("{ {baseName} }", apiClient.parameterToString({ {paramName} }));
80
- { {/headerParams} }
81
-
82
- final String[] accepts = {
83
- {{#produces} }"{ {mediaType} }"{ {#hasMore} }, { {/hasMore} }{ {/produces} }
84
- };
85
- final String accept = apiClient.selectHeaderAccept(accepts);
86
-
87
- final String[] contentTypes = {
88
- {{#consumes} }"{ {mediaType} }"{ {#hasMore} }, { {/hasMore} }{ {/consumes} }
89
- };
90
- final String contentType = apiClient.selectHeaderContentType(contentTypes);
91
-
92
- if(contentType.startsWith("multipart/form-data")) {
93
- boolean hasFields = false ;
94
- FormDataMultiPart mp = new FormDataMultiPart();
95
- {{#formParams} }{ {#notFile} }
96
- if ({ {paramName} } != null) {
97
- hasFields = true ;
98
- mp.field(" {{baseName}}" , apiClient.parameterToString({{paramName} }), MediaType.MULTIPART_FORM_DATA_TYPE);
99
- }
100
- { {/notFile} }{ {#isFile} }
101
- if ({ {paramName} } != null) {
102
- hasFields = true ;
103
- mp.field(" {{baseName}}" , {{paramName} }.getName());
104
- mp.bodyPart(new FileDataBodyPart("{ {baseName} }", { {paramName} }, MediaType.MULTIPART_FORM_DATA_TYPE));
105
- }
106
- { {/isFile} }{ {/formParams} }
107
- if(hasFields)
57
+ { {/required} }{ {/allParams} }
58
+
59
+ // create path and map variables
60
+ String path = "{ {path} }".replaceAll("\\{ format\\} ","json"){ {#pathParams} }
61
+ .replaceAll("\\{ " + " {{paramName} }" + "\\}", apiClient.escapeString({ {{paramName} }}.toString())){ {/pathParams} };
62
+
63
+ // query params
64
+ Map<String , String > queryParams = new HashMap<String , String >();
65
+ Map<String , String > headerParams = new HashMap<String , String >();
66
+ Map<String , String > formParams = new HashMap<String , String >();
67
+
68
+ { {#queryParams} }if ({ {paramName} } != null)
69
+ queryParams.put("{ {baseName} }", apiClient.parameterToString({ {paramName} }));
70
+ { {/queryParams} }
71
+
72
+ { {#headerParams} }if ({ {paramName} } != null)
73
+ headerParams.put("{ {baseName} }", apiClient.parameterToString({ {paramName} }));
74
+ { {/headerParams} }
75
+
76
+ final String[] accepts = {
77
+ {{#produces} }"{ {mediaType} }"{ {#hasMore} }, { {/hasMore} }{ {/produces} }
78
+ };
79
+ final String accept = apiClient.selectHeaderAccept(accepts);
80
+
81
+ final String[] contentTypes = {
82
+ {{#consumes} }"{ {mediaType} }"{ {#hasMore} }, { {/hasMore} }{ {/consumes} }
83
+ };
84
+ final String contentType = apiClient.selectHeaderContentType(contentTypes);
85
+
86
+ if(contentType.startsWith("multipart/form-data")) {
87
+ boolean hasFields = false ;
88
+ FormDataMultiPart mp = new FormDataMultiPart();
89
+ {{#formParams} }{ {#notFile} }
90
+ if ({ {paramName} } != null) {
91
+ hasFields = true ;
92
+ mp.field(" {{baseName}}" , apiClient.parameterToString({{paramName} }), MediaType.MULTIPART_FORM_DATA_TYPE);
93
+ }
94
+ { {/notFile} }{ {#isFile} }
95
+ if ({ {paramName} } != null) {
96
+ hasFields = true ;
97
+ mp.field(" {{baseName}}" , {{paramName} }.getName());
98
+ mp.bodyPart(new FileDataBodyPart("{ {baseName} }", { {paramName} }, MediaType.MULTIPART_FORM_DATA_TYPE));
99
+ }
100
+ { {/isFile} }{ {/formParams} }
101
+ if(hasFields)
108
102
postBody = mp;
109
- }
110
- else {
111
- {{#formParams} }{ {#notFile} }if ({ {paramName} } != null)
103
+ }
104
+ else {
105
+ {{#formParams} }{ {#notFile} }if ({ {paramName} } != null)
112
106
formParams.put("{ {baseName} }", apiClient.parameterToString({ {paramName} }));{ {/notFile} }
113
- { {/formParams} }
114
- }
107
+ { {/formParams} }
108
+ }
115
109
116
- try {
117
- String[] authNames = new String[] { {{#authMethods} }"{ {name} }"{ {#hasMore} }, { {/hasMore} }{ {/authMethods} } };
118
- String response = apiClient.invokeAPI(path, "{ {httpMethod} }", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
119
- if(response != null){
110
+ try {
111
+ String[] authNames = new String[] { {{#authMethods} }"{ {name} }"{ {#hasMore} }, { {/hasMore} }{ {/authMethods} } };
112
+ String response = apiClient.invokeAPI(path, "{ {httpMethod} }", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
113
+ if(response != null){
120
114
return {{#returnType} }({ {{returnType} }}) apiClient.deserialize(response, "{ {returnContainer} }", { {returnBaseType} }.class){ {/returnType} };
121
- }
122
- else {
115
+ }
116
+ else {
123
117
return {{#returnType} }null{ {/returnType} };
124
- }
125
- } catch (ApiException ex) {
126
- throw ex;
127
- }
128
- }
129
- { {/operation} }
118
+ }
119
+ } catch (ApiException ex) {
120
+ throw ex;
130
121
}
122
+ }
123
+ { {/operation} }
124
+ }
131
125
{ {/operations} }
0 commit comments