OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][SPRING] EnumConverterConfiguration does not use `modelNameSuffix`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- 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
OpenAPI generator generate the file EnumConverterConfiguration.java if the OA description includes at least one enum. The template does not take into account the generator configuration property modelNameSuffix, which is used to name the DTO models. The issue is then that the class EnumConverterConfiguration includes incorrect references to the DTO models.
openapi-generator version
6.2.1
OpenAPI declaration file content or url
See this OpenAPI description (note the use of enum)
Generation Details
- openapitools.json
- Command:
openapi-generator-cli generate
Content of EnumConverterConfiguration.java (here the value of modelNameSuffix is not used to name the models):
package org.sagebionetworks.challenge.configuration;
import org.sagebionetworks.challenge.model.dto.ChallengeStatus;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
@Configuration
public class EnumConverterConfiguration {
@Bean
Converter<String, ChallengeStatus> challengeStatusConverter() {
return new Converter<String, ChallengeStatus>() {
@Override
public ChallengeStatus convert(String source) {
return ChallengeStatus.fromValue(source);
}
};
}
}
List of DTO models generated (here the value of modelNameSuffix is correctly used to name the models):
$ ls -ahl apps/challenge-service/src/main/java/org/sagebionetworks/challenge/model/dto/
total 40K
drwxr-xr-x 2 vscode vscode 219 Dec 20 22:06 .
drwxr-xr-x 7 vscode vscode 75 Dec 19 19:36 ..
-rw-r--r-- 1 vscode vscode 3.8K Dec 20 20:15 BasicErrorDto.java
-rw-r--r-- 1 vscode vscode 3.3K Dec 20 20:15 ChallengeCreateRequestDto.java
-rw-r--r-- 1 vscode vscode 1.1K Dec 20 20:15 ChallengeDifficultyDto.java
-rw-r--r-- 1 vscode vscode 5.1K Dec 20 20:15 ChallengeDto.java
-rw-r--r-- 1 vscode vscode 986 Dec 20 20:15 ChallengeStatusDto.java
-rw-r--r-- 1 vscode vscode 6.4K Dec 20 20:15 ChallengesPageDto.java
-rw-r--r-- 1 vscode vscode 5.4K Dec 20 20:15 PageMetadataDto.java
Steps to reproduce
- Download the OA description (see above)
- Download the OA generator config file (see above)
- Run the OA generator:
openapi-generator-cli generate
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the linked OpenAPI declaration, openapitools.json, and the openapi-generator-cli generate command. Start by locating the template or entry point that generates EnumConverterConfiguration.java; done means its model references use modelNameSuffix consistently with generated DTOs such as ChallengeStatusDto.java.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100