Skip to content

[BUG] [Java] Cannot generate enum of type uri when using withXml-configOption #24236

Description

@Chrimle

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When using the java generator, and the configOption withXml=true, the generated enum will be annotated with invalid annotations.

Actual:

public enum ExampleUriEnum {
  
  @XmlEnumValue(URI.create("https://github.com/Chrimle/openapi-to-java-records-mustache-templates"))
  HTTPS_GITHUB_COM_CHRIMLE_OPENAPI_TO_JAVA_RECORDS_MUSTACHE_TEMPLATES(URI.create("https://github.com/Chrimle/openapi-to-java-records-mustache-templates")),
  
  @XmlEnumValue(URI.create("https://chrimle.github.io/openapi-to-java-records-mustache-templates/"))
  HTTPS_CHRIMLE_GITHUB_IO_OPENAPI_TO_JAVA_RECORDS_MUSTACHE_TEMPLATES_(URI.create("https://chrimle.github.io/openapi-to-java-records-mustache-templates/"));

//...

}

The XmlEnumValue-annotation only accepts Strings...

openapi-generator version

2.23.0

OpenAPI declaration file content or url

schema:

    ExampleUriEnum:
      type: string
      format: uri
      description: Example of an Enum with URI values
      enum:
        - "https://github.com/Chrimle/openapi-to-java-records-mustache-templates"
        - "https://chrimle.github.io/openapi-to-java-records-mustache-templates/"
Generation Details

configuration:

<generatorName>java</generatorName>
<configOptions>
    <withXml>true</withXml>
</configOptions>
Steps to reproduce

See above.

Related issues/PRs

None.

Suggest a fix

Might need intervention in the codegen, since {{{value}}} is currently causing the issue...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions