OpenAPITools / OpenAPITools/openapi-generator

spring-mvc generator prefixes String in enum when using "modelNamePrefix" or "modelNameSuffix"

Open
#2,691 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

spring-mvc generator prefixes String in enum when using "modelNamePrefix" or "modelNameSuffix"
which leads to compile errors.

openapi-generator version
			<groupId>org.openapitools</groupId>
			<artifactId>openapi-generator-maven-plugin</artifactId>
			<version>3.3.4</version>
OpenAPI declaration file content or url

create some enum like:
Version:
type: String
enum:
- 2.1.0
- 2.2.0

Command line used for generation
Steps to reproduce
					<configuration>
						<inputSpec>${project.basedir}/src/main/resources/openapi-3ds.yaml</inputSpec>
						<output>${project.build.directory}/generated-sources/openapi</output>
						<generatorName>spring</generatorName>
						<modelPackage>de.restapi.openapi.model</modelPackage>
						<apiPackage>de.restapi.openapi</apiPackage>
						<modelNamePrefix>OA</modelNamePrefix>
						<configOptions>
							<sourceFolder>openapi</sourceFolder>
							<library>spring-mvc</library>
							<interfaceOnly>true</interfaceOnly>
							<useBeanValidation>true</useBeanValidation>
							<dateLibrary>java8</dateLibrary>
							<java8>true</java8>
							<useTags>true</useTags>
						</configOptions>
Related issues/PRs
Suggest a fix/enhancement

i guess you need to exclude some class types from being prefixed.. like anythign from the JDK...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the spring generator, spring-mvc library, and modelNamePrefix or modelNameSuffix configuration shown in the report. Inspect the generator's model-name handling and generated enum output, then verify that JDK type names are not incorrectly prefixed and that the generated Java compiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.