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
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When marshaling an object, the MarshalJSON function is called and implemented for all of the objects. This calls ToMap(), which makes sure that all of the fields in the object are not empty - and if they are, it omits them. However, in the case where an object contains an inner object, it doesn't send the inner object to its inner ToMap() function, resulting in the marshaling happening only on the object's "first layer" of values.
Bug Report Checklist
Description
When marshaling an object, the MarshalJSON function is called and implemented for all of the objects. This calls ToMap(), which makes sure that all of the fields in the object are not empty - and if they are, it omits them. However, in the case where an object contains an inner object, it doesn't send the inner object to its inner ToMap() function, resulting in the marshaling happening only on the object's "first layer" of values.
openapi-generator version
7.9.0
OpenAPI declaration file content or url
example:
type LegacyCheckDefinitionDTO struct {
LegacyDefinitionDTO
TesterAccessId int64
json:"tester_access_id"
IdOnTester *string
json:"id_on_tester,omitempty"
Timeout *int32
json:"timeout,omitempty"
}
this is the MarshalJSON toMap() function -
func (o LegacyCheckDefinitionDTO) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
and this is the toMap() function -
func (o LegacyCheckDefinitionDTO) ToMap() (map[string]interface{}, error) {
toSerialize["tester_access_id"] = o.TesterAccessId
if !IsNil(o.IdOnTester) {
toSerialize["id_on_tester"] = o.IdOnTester
}
if !IsNil(o.Timeout) {
toSerialize["timeout"] = o.Timeout
}
return toSerialize, nil
The function doesn't take care of its inner object LegacyDefinitionDTO !
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
Add iteration on all of the objects and call toMap() on all of them!
The text was updated successfully, but these errors were encountered: