Skip to content

Commit 68f5856

Browse files
committed
fix non-nillable return types in api mock
1 parent 8cd20a5 commit 68f5856

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

languages/golang/templates/custom/api_mock.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ func (a {{{classname}}}ServiceMock) {{{nickname}}}(ctx context.Context{{#pathPar
3636
// {{#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.
3737
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) {
3838
if a.{{nickname}}ExecuteMock == nil {
39-
return {{#returnType}}nil, {{/returnType}}&http.Response{}, nil
39+
{{#returnType}}
40+
var localVarReturnValue {{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{.}}}
41+
{{/returnType}}
42+
return {{#returnType}}localVarReturnValue, {{/returnType}}&http.Response{}, nil
4043
}
4144

4245
return (*a.{{nickname}}ExecuteMock)(r)

0 commit comments

Comments
 (0)