[BUG][Maven] importMappings not working
See original GitHub issueHi
maven plugin is not working as expected when trying to use an already existing class.
Here (https://openapi-generator.tech/docs/usage#target-external-models) are the instructions to generate code using a existing class.
It works when using openapi-generator client. When I execute this
openapi-generator generate \
-i https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml \
-g java \
-o out \
--language-specific-primitives=Pet \
--import-mappings=Pet=com.yourpackage.models.Pet
Then Pet.java, as expected, does not exist in src/main/java/org/openapitools/client/model/
But when doing the same with maven plugin
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.2.2</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml</inputSpec>
<generatorName>java</generatorName>
<configOptions>
<languageSpecificPrimitives>Pet</languageSpecificPrimitives>
<importMappings>Pet=com.yourpackage.models.Pet</importMappings>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Then Pet.java does exist in src/main/java/org/openapitools/client/model/ but it shouldn’t
openapi-generator-maven-plugin 4.2.2 openapi-generator-cli 4.2.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
swagger-codegen-maven-plugin ignores the importmapping i ...
The importMappings and importMapping tags do not work, you are right. But there is a workaround;
Read more >swagger-maven-plugin does not seem to support the import ...
I want to pass a list of my own import mappings to the generator using the swagger-maven-plugin so that these classes don't get...
Read more >use imported types as query param - SmartBear Community
is it possible to use an imported type (via importMapping) not only as the return type for an endpoint, but as its parameter...
Read more >[BUG][MAVEN] Import Mappings not working with ... - Devscope.io
OpenAPITools/openapi-generator: [BUG][MAVEN] Import Mappings not working with ... Code generation is not working after upgrade to version 6.0.1 from 5.3.0, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Many thanks @uortiz, that was pretty hidden
I wonder if it’s possible to make this change clear in the documentation or to show some kind of warning when generating sources.
Also, I don’t really get this “backwards-compatibility” if it won’t work. I think it’s preferable to show an error instead of not complaining at all but also do nothing, it’s confusing.
Anyways, thanks again
Related issue https://github.com/OpenAPITools/openapi-generator/issues/8803