Skip to content

[BUG][spring/spring-boot] Missing import of URI in Generated EnumConverter #23325

@Chrimle

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

Generating an enum with type URI (strings), the generated EnumConverterConfiguration.java will not import java.util.URI, resulting in compilation errors...

openapi-generator version

7.20.0

OpenAPI declaration file content or url
    ExampleUriEnum:
      type: string
      format: uri
      description: Example of an Enum with URI values
      enum:
        - "https://another-example.com"
        - "https:/example.com"
Generation Details

GeneratorName: spring
library: spring-boot

Steps to reproduce
@Bean(name = "org.openapitools.configuration.EnumConverterConfiguration.exampleUriEnumConverter")
    Converter<URI, ExampleUriEnum> exampleUriEnumConverter() {
        return new Converter<URI, ExampleUriEnum>() {
            @Override
            public ExampleUriEnum convert(URI source) {
                return ExampleUriEnum.fromValue(source);
            }
        };
    }

The URI-class is not imported:

package org.openapitools.configuration;

import io.github.chrimle.o2jrm.standard.DeprecatedExampleEnum;
import io.github.chrimle.o2jrm.standard.ExampleEnum;
import io.github.chrimle.o2jrm.standard.ExampleEnumWithIntegerValues;
import io.github.chrimle.o2jrm.standard.ExampleImplementsEnum;
import io.github.chrimle.o2jrm.standard.ExampleNullableEnum;
import io.github.chrimle.o2jrm.standard.ExampleTwoImplementsEnum;
import io.github.chrimle.o2jrm.standard.ExampleUriEnum;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions