-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code generation fails when components are named identically to one of their enum properties #2050
Comments
Jonnty
added a commit
to Jonnty/guardrail
that referenced
this issue
Nov 11, 2024
…oid naming conflicts Previously, when a property was named the same as its component, references to the component class were misinterpreted as references to the property class, causing errors. Fully qualifying the references to each should prevent this from happening. A regression test covering a minimal failing case is included. Fixes issue guardrail-dev#2050
Jonnty
added a commit
to Jonnty/guardrail
that referenced
this issue
Nov 11, 2024
…oid naming conflicts Previously, when a property was named the same as its component, references to the component class were misinterpreted as references to the property class, causing errors. Fully qualifying the references to each should prevent this from happening. A regression test covering a minimal failing case is included. Fixes issue guardrail-dev#2050
Jonnty
added a commit
to Jonnty/guardrail
that referenced
this issue
Nov 11, 2024
Previously, when a property was named the same as its component, references to the component class and property class conflicted, causing errors. Fully qualifying the references to each should prevent this from happening. A regression test covering a minimal failing case is included. Fixes issue guardrail-dev#2050
Jonnty
added a commit
to Jonnty/guardrail
that referenced
this issue
Nov 11, 2024
Previously, when a property was named the same as its component, references to the component class and property class conflicted, causing errors. Fully qualifying the references to each should prevent this from happening. A regression test covering a minimal failing case is included. Fixes issue guardrail-dev#2050
Jonnty
added a commit
to Jonnty/guardrail
that referenced
this issue
Nov 11, 2024
Previously, when a property was named the same as its component, references to the component class and property class conflicted, causing errors. Fully qualifying the references to each should prevent this from happening. A regression test covering a minimal failing case is included. Fixes issue guardrail-dev#2050
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been getting errors when generating code for a YAML OpenAPI 3 spec (this one, incidentally). They appear to be happen when one of the enum properties of a component is the same as the component itself. The cause seems to be that attempts to reference the component class are taken to be references to the identically named property object within the class when such an object happens to exist. (This doesn't happen for standard, non-enum strings as no child object is generated.)
The conflict is not case-sensitive, as generated class/object names are automatically camel cased.
I think the suggested fix for #1147 - fully qualifying component class names within generated code - would probably fix this as well.
I've narrowed this down into a minimal failing case - I get the following error when attempting to generate code for the specification below it by running
sbt compile
on a project using sbt-guardrail 1.0.0-M1.Error
Spec used
Code generated (Test.scala)
The text was updated successfully, but these errors were encountered: