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
If an object definition is referenced from an allOf array, and that definition includes inline object definitions, those inline definitions are expanded once per allOf reference. Instead, they should be expanded exactly once, and then referenced by name in each parent struct.
Here, the Common definition is emitted uselessly (Top doesn't use it) but the object type defined inline by Common is emitted and referenced as CommonInfo.
Common and CommonInfo are both emitted but unused. When Top references the ...Info struct, it produces a specialized version only used by Top. If Common were referenced in multiple allOf arrays, the ...Info struct would be replicated once for each reference, each time named after the referencer.
I dug into the code a bit, but this seems hard to fix without a substantial refactor. AFAICT, every Schema would need to carry the name of its parent definition, if any, and Schema has nowhere to put this data (without misusing an existing field).
The text was updated successfully, but these errors were encountered:
If an object definition is referenced from an
allOf
array, and that definition includes inline object definitions, those inline definitions are expanded once perallOf
reference. Instead, they should be expanded exactly once, and then referenced by name in each parent struct.For example, consider this schema:
Assuming the root structure is named
Top
, I'd expect this generated code:Here, the
Common
definition is emitted uselessly (Top
doesn't use it) but the object type defined inline byCommon
is emitted and referenced asCommonInfo
.Schemafy actually produces this code:
Common
andCommonInfo
are both emitted but unused. WhenTop
references the...Info
struct, it produces a specialized version only used byTop
. IfCommon
were referenced in multipleallOf
arrays, the...Info
struct would be replicated once for each reference, each time named after the referencer.I dug into the code a bit, but this seems hard to fix without a substantial refactor. AFAICT, every
Schema
would need to carry the name of its parent definition, if any, andSchema
has nowhere to put this data (without misusing an existing field).The text was updated successfully, but these errors were encountered: