[scala-http4s] Preserve underscores in enum names#23842
Open
anupamchaubey wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 15 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="output/src/main/scala/org/openapitools/client/models/package.scala">
<violation number="1" location="output/src/main/scala/org/openapitools/client/models/package.scala:37">
P1: Custom circe codecs for Json break native JSON handling: decode only accepts string tokens, encode double-encodes non-string values</violation>
</file>
<file name="output/src/main/scala/org/openapitools/client/apis/BaseClient.scala">
<violation number="1" location="output/src/main/scala/org/openapitools/client/apis/BaseClient.scala:77">
P2: Form parameters collapse repeated keys into comma-joined single values, breaking multi-valued form field serialization. UrlForm supports multiple values per key natively; values should be mapped directly without grouping and comma-joining.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| @@ -0,0 +1,46 @@ | |||
| /** Test | |||
Contributor
There was a problem hiding this comment.
P1: Custom circe codecs for Json break native JSON handling: decode only accepts string tokens, encode double-encodes non-string values
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At output/src/main/scala/org/openapitools/client/models/package.scala, line 37:
<comment>Custom circe codecs for Json break native JSON handling: decode only accepts string tokens, encode double-encodes non-string values</comment>
<file context>
@@ -0,0 +1,46 @@
+ given encodeLocalDate: Encoder[LocalDate] =
+ Encoder.encodeString.contramap[LocalDate](_.toString)
+
+ given decodeJson: Decoder[Json] =
+ Decoder.decodeString.map(str => Json.fromString(str))
+
</file context>
| case _Authorization.ApiKey(name, value) => | ||
| request.putHeaders(Header.Raw(CIString(name), value)) | ||
| } | ||
| val formBody = formParameters.map { x => |
Contributor
There was a problem hiding this comment.
P2: Form parameters collapse repeated keys into comma-joined single values, breaking multi-valued form field serialization. UrlForm supports multiple values per key natively; values should be mapped directly without grouping and comma-joining.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At output/src/main/scala/org/openapitools/client/apis/BaseClient.scala, line 77:
<comment>Form parameters collapse repeated keys into comma-joined single values, breaking multi-valued form field serialization. UrlForm supports multiple values per key natively; values should be mapped directly without grouping and comma-joining.</comment>
<file context>
@@ -0,0 +1,89 @@
+ case _Authorization.ApiKey(name, value) =>
+ request.putHeaders(Header.Raw(CIString(name), value))
+ }
+ val formBody = formParameters.map { x =>
+ UrlForm(x.groupBy(_._1).map { case (k, v) => (k, v.map(_._2).mkString(",")) }.toSeq*)
+ }
</file context>
7e29255 to
0becbda
Compare
0becbda to
7630370
Compare
anupamchaubey
commented
May 22, 2026
Author
anupamchaubey
left a comment
There was a problem hiding this comment.
@maintainers could someone approve/re-run the workflows?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes an issue in the
scala-http4sgenerator where enum entries containing underscores are incorrectly camelized during generation.For example:
was previously generated as:
ActiveStatusinstead of preserving the valid Scala identifier:
ACTIVE_STATUSRoot Cause
EnumEntryLambdacurrently calls:which delegates to
camelize()and removes underscores.This behavior is appropriate for general identifiers, but not for enum entries that are already valid Scala identifiers.
Fix
Added a dedicated
formatEnumIdentifier()helper inAbstractScalaCodegenwhich:ScalaHttp4sClientCodegen.EnumEntryLambdanow uses this helper instead offormatIdentifier().Verification
Generated models using:
now correctly produce:
Fixes #23841
PR checklist
masterbranch.Summary by cubic
Preserves SCREAMING_SNAKE_CASE enum entry names in the
scala-http4sgenerator by avoiding camelization, so values like ACTIVE_STATUS stay unchanged. Reserved words are escaped and names are sanitized.formatEnumIdentifier()inAbstractScalaCodegento preserve SCREAMING_SNAKE_CASE, apply special-char replacements and sanitization, escape reserved words, otherwise fall back toformatIdentifier().ScalaHttp4sClientCodegen.EnumEntryLambdato useformatEnumIdentifier()instead offormatIdentifier().Written for commit 7630370. Summary will update on new commits. Review in cubic