OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] Tag <generatorName> not working
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
According to the description you have to configure the generator plugin as follows:
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
<generatorName>java</generatorName>
...
</configuration>
But this results in:
MojoExecutionException: The generator requires 'generatorName'. Refer to documentation for a list of options.
The tag is recognized, however, what you can see that another error is thrown if you specify any nonsense as a value
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
<generatorName>nonsense</generatorName>
...
</configuration>
this results in:
GeneratorNotFoundException: Can't load config class with name 'nonsense'
The only way to get around this error is to write the generator name in the properties section of the pom.xml, then the tag can also be completely deleted from the section of the generator.
<properties>
...
<openapi-generator-maven-plugin.version>5.3.0</openapi-generator-maven-plugin.version>
<openapi.generator.maven.plugin.generatorName>spring</openapi.generator.maven.plugin.generatorName>
...
</properties>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
...
</build>
This works, but it is not really useful. If you need different generator names, this workaround no longer works.
openapi-generator version
All versions > 4.3.1
Generation Details
Tested with:
Openapi-Generator-Plugin 5.0.0 to 5.3.0
AdoptOpenJdk 11
Intellij Ultimate 2021.2
Spring Boot 2.5.4
Maven 3.6.3
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
Start by reproducing the Maven plugin configuration from the issue with generatorName inside the execution's configuration, using the listed OpenAPI Generator versions. Compare it with the working pom.xml properties workaround and inspect how the plugin resolves generatorName. Done means execution-level generatorName works and different executions can select different generators.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100