You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{! TEMPLATE CUSTOMIZATION - BEGIN - use the GenericOpenAPIError struct from the core module instead of the one generated by OpenAPI generator by default}}
{{! TEMPLATE CUSTOMIZATION - END - use the GenericOpenAPIError struct from the core module instead of the one generated by OpenAPI generator by default}}
133
139
}
134
140
@@ -142,27 +148,37 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
142
148
{{#required}}
143
149
{{^isPathParam}}
144
150
if r.{{paramName}} == nil {
145
-
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} is required and must be specified")
151
+
{{! TEMPLATE CUSTOMIZATION - BEGIN - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
152
+
return {{#returnType}}localVarReturnValue, {{/returnType}} reportError("{{paramName}} is required and must be specified")
153
+
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
146
154
}
147
155
{{/isPathParam}}
148
156
{{#minItems}}
149
157
if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minItems}} {
150
-
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minItems}} elements")
158
+
{{! TEMPLATE CUSTOMIZATION - BEGIN - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
159
+
return {{#returnType}}localVarReturnValue, {{/returnType}} reportError("{{paramName}} must have at least {{minItems}} elements")
160
+
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
151
161
}
152
162
{{/minItems}}
153
163
{{#maxItems}}
154
164
if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) > {{maxItems}} {
155
-
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxItems}} elements")
165
+
{{! TEMPLATE CUSTOMIZATION - BEGIN - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
166
+
return {{#returnType}}localVarReturnValue, {{/returnType}} reportError("{{paramName}} must have less than {{maxItems}} elements")
167
+
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
156
168
}
157
169
{{/maxItems}}
158
170
{{#minLength}}
159
171
if strlen({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minLength}} {
160
-
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minLength}} elements")
172
+
{{! TEMPLATE CUSTOMIZATION - BEGIN - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
173
+
return {{#returnType}}localVarReturnValue, {{/returnType}} reportError("{{paramName}} must have at least {{minLength}} elements")
174
+
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
161
175
}
162
176
{{/minLength}}
163
177
{{#maxLength}}
164
178
if strlen({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) > {{maxLength}} {
165
-
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxLength}} elements")
179
+
{{! TEMPLATE CUSTOMIZATION - BEGIN - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
180
+
return {{#returnType}}localVarReturnValue, {{/returnType}} reportError("{{paramName}} must have less than {{maxLength}} elements")
181
+
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
166
182
}
167
183
{{/maxLength}}
168
184
{{#minimum}}
@@ -173,7 +189,9 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
173
189
{{^isString}}
174
190
if {{^isPathParam}}*{{/isPathParam}}r.{{paramName}} < {{minimum}} {
175
191
{{/isString}}
176
-
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be greater than {{minimum}}")
192
+
{{! TEMPLATE CUSTOMIZATION - BEGIN - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
193
+
return {{#returnType}}localVarReturnValue, {{/returnType}} reportError("{{paramName}} must be greater than {{minimum}}")
194
+
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
177
195
}
178
196
{{/minimum}}
179
197
{{#maximum}}
@@ -184,7 +202,9 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
184
202
{{^isString}}
185
203
if {{^isPathParam}}*{{/isPathParam}}r.{{paramName}} > {{maximum}} {
186
204
{{/isString}}
187
-
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be less than {{maximum}}")
205
+
{{! TEMPLATE CUSTOMIZATION - BEGIN - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
206
+
return {{#returnType}}localVarReturnValue, {{/returnType}} reportError("{{paramName}} must be less than {{maximum}}")
207
+
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
188
208
}
189
209
{{/maximum}}
190
210
{{/required}}
@@ -319,7 +339,9 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
410
440
}
411
441
}
412
442
@@ -445,14 +475,20 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
445
475
{{! TEMPLATE CUSTOMIZATION - BEGIN - use the GenericOpenAPIError struct from the core module instead of the one generated by OpenAPI generator by default}}
446
476
newErr.ErrorMessage = err.Error()
447
477
{{! TEMPLATE CUSTOMIZATION - END - use the GenericOpenAPIError struct from the core module instead of the one generated by OpenAPI generator by default}}
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
449
481
}
450
482
{{! TEMPLATE CUSTOMIZATION - BEGIN - use the GenericOpenAPIError struct from the core module instead of the one generated by OpenAPI generator by default}}
{{! TEMPLATE CUSTOMIZATION - END - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
465
503
}
466
504
467
505
{{#returnType}}
@@ -474,11 +512,15 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
474
512
ErrorMessage: err.Error(),
475
513
}
476
514
{{! TEMPLATE CUSTOMIZATION - END - use the GenericOpenAPIError struct from the core module instead of the one generated by OpenAPI generator by default}}
Copy file name to clipboardExpand all lines: languages/golang/templates/custom/api_mock.mustache
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,6 @@ package {{packageName}}
4
4
{{#operations}}
5
5
import (
6
6
"context"
7
-
"net/http"
8
7
)
9
8
10
9
// assert the implementation matches the interface
@@ -15,7 +14,7 @@ var _ {{classname}} = &{{classname}}ServiceMock{}
15
14
type {{classname}}ServiceMock struct {
16
15
{{#operation}}
17
16
// {{#isDeprecated}}Deprecated: {{/isDeprecated}}{{nickname}}ExecuteMock can be populated to implement the behavior of the {{nickname}}Execute function of this mock
@@ -34,12 +33,12 @@ func (a {{{classname}}}ServiceMock) {{{nickname}}}(ctx context.Context{{#pathPar
34
33
}
35
34
36
35
// {{#isDeprecated}}Deprecated: {{/isDeprecated}}{{nickname}}Execute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the {{nickname}}ExecuteMock field in the {{classname}}ServiceMock struct.
37
-
func (a {{{classname}}}ServiceMock) {{nickname}}Execute(r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) ({{#returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}, {{/returnType}}*http.Response, error) {
36
+
func (a {{{classname}}}ServiceMock) {{nickname}}Execute(r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) ({{#returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}, {{/returnType}} error) {
38
37
if a.{{nickname}}ExecuteMock == nil {
39
38
{{#returnType}}
40
39
var localVarReturnValue {{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}
0 commit comments