cloudwan / gohan

Gohan is an API Gateway Server written by Go that makes it easy for developers to create and maintain REST-style API
http://www.slideshare.net/natiueno/gohan-61170476
Other
109 stars 44 forks source link

CW-1782: fully recursively populate default values. #787

Closed cierpuchaw closed 3 years ago

cierpuchaw commented 3 years ago

Middle level objects do not always have a default value but their children might. Use DefaultMask (as it's fully computed) instead of only Default in order to handle such cases.

cierpuchaw commented 3 years ago

This is probably the most important piece of context for this PR: https://github.com/cloudwan/gohan/blob/master/schema/property.go#L231

If schema subobject contains a "default:" clause then it's used for the value of DefaultMask. Otherwise, if the subobject is an object (instead of an array or a "primitive" type) we recursively cache default values all the way down.