Bug Report Checklist
Description
The EnumEntryLambda inner class in
ScalaHttp4sClientCodegen.java (line ~628)
calls formatIdentifier(fragment, true) on enum entry values. This delegates to AbstractScalaCodegen.formatIdentifier() which runs camelize() — stripping all underscores.
So an enum value like ACTIVE_STATUS becomes ACTIVESTATUS in the generated Scala code, which is incorrect — ACTIVE_STATUS is a perfectly valid Scala identifier and should be preserved as-is.
openapi-generator version
7.13.0
OpenAPI declaration file content or url
openapi: "3.0.3"
info:
title: Test
version: "1.0"
paths: {}
components:
schemas:
MyStatus:
required:
- status
type: object
additionalProperties: false
properties:
status:
description: current status
enum:
- ACTIVE_STATUS
- INACTIVE_STATUS
type: string
Generation Details
openapi-generator-cli generate \
-g scala-http4s \
-i spec.yaml \
-o output/
--global-property models
Steps to reproduce
- Generate code with the spec above using
scala-http4s generator
- Look at the generated enum values —
ACTIVE_STATUS becomes ACTIVESTATUS, INACTIVE_STATUS becomes INACTIVESTATUS
Expected: ACTIVE_STATUS stays ACTIVE_STATUS .
Actual: All enum values are run through camelize(), which strips underscores.
Related issues/PRs
Suggest a fix
In ScalaHttp4sClientCodegen.java, change EnumEntryLambda.formatFragment() to preserve valid identifiers and only backtick-escape invalid ones:
private class EnumEntryLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
if (fragment.matches("^[A-Za-z_][A-Za-z0-9_]*$") && !isReservedWord(fragment)) {
return fragment;
}
return "`" + fragment + "`";
}
}
Bug Report Checklist
Description
The
EnumEntryLambdainner class inScalaHttp4sClientCodegen.java(line ~628)calls
formatIdentifier(fragment, true)on enum entry values. This delegates toAbstractScalaCodegen.formatIdentifier()which runscamelize()— stripping all underscores.So an enum value like
ACTIVE_STATUSbecomesACTIVESTATUSin the generated Scala code, which is incorrect —ACTIVE_STATUSis a perfectly valid Scala identifier and should be preserved as-is.openapi-generator version
7.13.0OpenAPI declaration file content or url
Generation Details
Steps to reproduce
scala-http4sgeneratorACTIVE_STATUSbecomesACTIVESTATUS,INACTIVE_STATUSbecomesINACTIVESTATUSExpected:
ACTIVE_STATUSstaysACTIVE_STATUS.Actual: All enum values are run through
camelize(), which strips underscores.Related issues/PRs
Suggest a fix
In
ScalaHttp4sClientCodegen.java, changeEnumEntryLambda.formatFragment()to preserve valid identifiers and only backtick-escape invalid ones: