Description
When StatusCode < 300, a.client.decode returns an error but it is not handled in the code which returns a nil error. There is a comment that mentions some kind of handling that is necessary but the handling doesn't exist.
|
if localVarHttpResponse.StatusCode < 300 { |
|
// If we succeed, return the data, otherwise pass on to decode error. |
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) |
|
if err == nil { |
|
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err |
|
} |
|
} |
However, the error is not handled and the next thing that happens is that error is returned as a nil at the end of the function:
|
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, nil |
openapi-generator version
master: 8507916
OpenAPI declaration file content or url
n/a
Command line used for generation
n/a
Steps to reproduce
Make an API call that generates a decode error, e.g. if model schema doesn't return what is returned by the API.
Related issues/PRs
n/a
Suggest a fix/enhancement
Implement GenericOpenAPIError similar to when StatusCode >= 300 with GenericOpenAPIError.
|
if localVarHttpResponse.StatusCode >= 300 { |
|
newErr := GenericOpenAPIError{ |
|
body: localVarBody, |
|
error: localVarHttpResponse.Status, |
|
} |
|
{{#responses}} |
|
{{#dataType}} |
|
if localVarHttpResponse.StatusCode == {{{code}}} { |
|
var v {{{dataType}}} |
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) |
|
if err != nil { |
|
newErr.error = err.Error() |
|
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr |
|
} |
Description
When StatusCode < 300,
a.client.decodereturns an error but it is not handled in the code which returns anilerror. There is a comment that mentions some kind of handling that is necessary but the handling doesn't exist.openapi-generator/modules/openapi-generator/src/main/resources/go/api.mustache
Lines 276 to 282 in 8507916
However, the error is not handled and the next thing that happens is that error is returned as a nil at the end of the function:
openapi-generator/modules/openapi-generator/src/main/resources/go/api.mustache
Line 307 in 8507916
openapi-generator version
master: 8507916
OpenAPI declaration file content or url
n/a
Command line used for generation
n/a
Steps to reproduce
Make an API call that generates a decode error, e.g. if model schema doesn't return what is returned by the API.
Related issues/PRs
n/a
Suggest a fix/enhancement
Implement
GenericOpenAPIErrorsimilar to when StatusCode >= 300 withGenericOpenAPIError.openapi-generator/modules/openapi-generator/src/main/resources/go/api.mustache
Lines 285 to 298 in 8507916