Bug Report Checklist
Description
func decode() in client.mustache does not handle type assertion correctly due to missing return command (row 418).
|
func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { |
|
if len(b) == 0 { |
|
return nil |
|
} |
|
if s, ok := v.(*string); ok { |
|
*s = string(b) |
|
return nil |
|
} |
|
if xmlCheck.MatchString(contentType) { |
|
if err = xml.Unmarshal(b, v); err != nil { |
|
return err |
|
} |
|
return nil |
|
} |
|
if jsonCheck.MatchString(contentType) { |
|
if actualObj, ok := v.(interface{GetActualInstance() interface{}}); ok { // oneOf, anyOf schemas |
|
if unmarshalObj, ok := actualObj.(interface{UnmarshalJSON([]byte) error}); ok { // make sure it has UnmarshalJSON defined |
|
if err = unmarshalObj.UnmarshalJSON(b); err!= nil { |
|
return err |
|
} |
|
} else { |
|
errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") |
|
} |
|
} else if err = json.Unmarshal(b, v); err != nil { // simple model |
|
return err |
|
} |
|
return nil |
|
} |
|
return errors.New("undefined response type") |
|
} |
openapi-generator version
Master
Suggest a fix
Add a return to this line
|
errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") |
Bug Report Checklist
Description
func decode() in client.mustache does not handle type assertion correctly due to missing return command (row 418).
openapi-generator/modules/openapi-generator/src/main/resources/go/client.mustache
Lines 397 to 426 in 634c4c0
openapi-generator version
Master
Suggest a fix
Add a return to this line
openapi-generator/modules/openapi-generator/src/main/resources/go/client.mustache
Line 418 in 634c4c0