Skip to content

[FEAT] [jaxrs-spec] Support useEnumCaseInsensitive ConfigOption - #24157

Merged
wing328 merged 2 commits into
OpenAPITools:masterfrom
hamburml:AddEnumCaseInsensitiveJaxrsSpec
Jul 6, 2026
Merged

[FEAT] [jaxrs-spec] Support useEnumCaseInsensitive ConfigOption#24157
wing328 merged 2 commits into
OpenAPITools:masterfrom
hamburml:AddEnumCaseInsensitiveJaxrsSpec

Conversation

@hamburml

@hamburml hamburml commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Add USE_ENUM_CASE_INSENSITIVE for jaxrs-spec generator, mustache files already have that.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Adds a useEnumCaseInsensitive option to the jaxrs-spec generator for case-insensitive String enum matching. Includes a new Petstore sample with tests and updates docs for jaxrs-spec and jaxrs-cxf-cdi.

  • New Features
    • New CLI/config option useEnumCaseInsensitive (default: false) in org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen; exposed to templates via additionalProperties.
    • Added bin/configs/jaxrs-spec-enum.yaml and generated samples/server/petstore/jaxrs-spec-enum (tests validate case-insensitive .fromValue() for string enums). Updated docs for jaxrs-spec and jaxrs-cxf-cdi.

Written for commit 7d16a45. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@hamburml

Copy link
Copy Markdown
Contributor Author

@wing328 could you please check the pr if u find time?

@hamburml hamburml changed the title Add USE_ENUM_CASE_INSENSITIVE, mustache files already have that. [jaxrs-spec] Add USE_ENUM_CASE_INSENSITIVE, mustache files already have that. Jun 30, 2026

@Chrimle Chrimle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Surprised that there are no samples being updated though?

@hamburml
hamburml force-pushed the AddEnumCaseInsensitiveJaxrsSpec branch from 6125be9 to d96f477 Compare July 2, 2026 18:05
@hamburml
hamburml force-pushed the AddEnumCaseInsensitiveJaxrsSpec branch from d96f477 to 7d16a45 Compare July 2, 2026 18:10
@hamburml

hamburml commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@Chrimle Just added them :) wasnt sure because a lot of tests for the java generators are empty and have todos but I guess it doesnt hurt to add them for that case.

@JsonCreator
public static EnumClass fromValue(String value) {
for (EnumClass b : EnumClass.values()) {
if (b.value.equalsIgnoreCase(value)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good 👍

@JsonCreator
public static IntegerEnum fromValue(Integer value) {
for (IntegerEnum b : IntegerEnum.values()) {
if (b.value.equals(value)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also good 👍

@JsonCreator
public static StatusEnum fromValue(String value) {
for (StatusEnum b : StatusEnum.values()) {
if (b.value.equalsIgnoreCase(value)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also good 👍 (inner enum)

* Gets or Sets OuterEnumDefaultValue
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.24.0-SNAPSHOT")
public enum OuterEnumDefaultValue {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this class suggests there should be some default value? 🤔 Perhaps unrelated to this change though...

@JsonCreator
public static OuterEnumInteger fromValue(Integer value) {
for (OuterEnumInteger b : OuterEnumInteger.values()) {
if (b.value.equals(value)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 (outer integer enum)

* Gets or Sets OuterEnumIntegerDefaultValue
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.24.0-SNAPSHOT")
public enum OuterEnumIntegerDefaultValue {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same weird thing here... 🤔

public class StringEnumTest {

@Test
public void fromValueUsesCaseInsensitiveMatching() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@Chrimle Chrimle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Did spot some odd Enum-classes though, related to "default"-values. But could be out-of-scope for this, and potentially another feature that isn't properly supported yet...

@Chrimle

Chrimle commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Suggestion for PR title:

[FEAT] [jaxrs-spec] Support useEnumCaseInsensitive ConfigOption

@wing328 wing328 added this to the 7.24.0 milestone Jul 6, 2026
@wing328
wing328 merged commit ddeb30a into OpenAPITools:master Jul 6, 2026
37 checks passed
@wing328 wing328 changed the title [jaxrs-spec] Add USE_ENUM_CASE_INSENSITIVE, mustache files already have that. [FEAT] [jaxrs-spec] Support useEnumCaseInsensitive ConfigOption Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants