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
Describe the bug
When we have a sealed trait and subtypes reside inside trait's companion,
we also need to make sure that any other object referencing concrete subtype directly, will nest under companion.
To Reproduce
Try to generate from the following yaml:
Expected behaviour
when subtypes are referenced directly from outside the shared companion, they should prepend the encapsulating path to the type.
If inside the shared companion, then bare reference should be fine: if Lion was part of Animals oneOf => it would have extended same sealed trait, and would have resided inside the companion, thus can (and should) reference Zebra directly.
edge case: make sure inner types don't collide with imported types.
The text was updated successfully, but these errors were encountered:
hochgi
changed the title
[gen] Concrete subtypes of a sum type referenced directly with nesting or proper import
[gen] Concrete subtypes of a sum type referenced directly without nesting or proper import
May 27, 2024
Describe the bug
When we have a sealed trait and subtypes reside inside trait's companion,
we also need to make sure that any other object referencing concrete subtype directly, will nest under companion.
To Reproduce
Try to generate from the following yaml:
And you'll see the code does not compile:
![Screenshot 2024-05-26 at 23 41 11](https://private-user-images.githubusercontent.com/881075/333908570-4cb494b4-8f9d-4b09-a6fd-6a940675b756.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEyNDE2MDUsIm5iZiI6MTcyMTI0MTMwNSwicGF0aCI6Ii84ODEwNzUvMzMzOTA4NTcwLTRjYjQ5NGI0LThmOWQtNGIwOS1hNmZkLTZhOTQwNjc1Yjc1Ni5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcxN1QxODM1MDVaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yNTIyNGUzZTY0YmMyODc5ZmExMGNmNGVkZDJlNGFmYWU4ZmUyNmU1YTMxZTdlNmMyNDBmNWY0ZjBjYjk4ZDAwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.tMUcKrgwf1j54dvgRXIdGHWyoW3Uq9O-fRVOiZqZjFo)
this is the generated code for
Lion
:but it should have been:
Since
Zebra
is nested underAnimal
:Expected behaviour
when subtypes are referenced directly from outside the shared companion, they should prepend the encapsulating path to the type.
If inside the shared companion, then bare reference should be fine: if
Lion
was part ofAnimal
soneOf
=> it would have extended same sealed trait, and would have resided inside the companion, thus can (and should) referenceZebra
directly.edge case: make sure inner types don't collide with imported types.
The text was updated successfully, but these errors were encountered: