Skip to content
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

Incorrect names for enum values #1958

Open
OlegYch opened this issue Mar 7, 2024 · 4 comments
Open

Incorrect names for enum values #1958

OlegYch opened this issue Mar 7, 2024 · 4 comments

Comments

@OlegYch
Copy link

OlegYch commented Mar 7, 2024

For a enum like this

"enum": [
                "datetime",
                "-datetime"
              ]

guardrail will generate two objects with same name Datetime

@blast-hardcheese
Copy link
Member

@OlegYch Interesting, thank you for reporting!

This scales, unfortunately, "--datetime" etc, so coming up with useful names to disambiguate is going to be tricky.

Reaching out to the JVM for a universal solution here seems the way to completely solve this problem, at the expense of the names it would generate:

scala> java.lang.Character.getName('-')
val res0: String = HYPHEN-MINUS

scala> java.lang.Character.getName('/')
val res1: String = SOLIDUS

scala> java.lang.Character.getName('\\')
val res2: String = REVERSE SOLIDUS

At the very least they'd be unique, and we'd only need to interpolate them in the case of disambiguation, so maybe it's alright that the names are not good.

What do you think?

@OlegYch
Copy link
Author

OlegYch commented Mar 7, 2024

i think the usual quoting is enough, eg:

case object Datetime
case object `-datetime`

@blast-hardcheese
Copy link
Member

Possibly in Scala, but Java will have this problem. I guess we could do both, each language having their own experience.

@OlegYch
Copy link
Author

OlegYch commented Mar 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants