Skip to content

Inner URI Enums with useEnumCaseInsensitive causes compilation errors #20952

Closed

Description

@Chrimle

if (b.value.{{^isString}}equals{{/isString}}{{#isString}}{{#useEnumCaseInsensitive}}equalsIgnoreCase{{/useEnumCaseInsensitive}}{{^useEnumCaseInsensitive}}equals{{/useEnumCaseInsensitive}}{{/isString}}(value)) {

The current implementation of inner enum classes are not working for:

  • <library>okhttp-gson</library>
  • <enumCaseInsensitive>true</enumCaseInsensitive>
  • type: string
  • format: uri

This would generate:

public static ExampleInnerThreeEnum fromValue(URI value) {
      for (ExampleInnerThreeEnum b : ExampleInnerThreeEnum.values()) {
        if (b.value.equalsIgnoreCase(value)) {
          return b;
        }
      }
      throw new IllegalArgumentException("Unexpected value '" + value + "'");
    }

Which will cause compilation errors, since URI does not have a method equalsIgnoreCase.

Activity

  1. Chrimle commented on Mar 23, 2025

    @Chrimle
    ContributorAuthor

    I fixed this bug in my project by updating the generation of the fromValue in inner enum classes like so:
    https://github.com/Chrimle/openapi-to-java-records-mustache-templates/pull/379/files#diff-aeb7136d23f600e2b94b74af6d963df0114170da689c37a60bc64bbccea4565cR100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions