Open uweschaefer opened 2 years ago
looks like https://github.com/OpenAPITools/openapi-generator/pull/7014 might solve the issue
Hi
I have the same problem. In my opinion, a breaking change has been added in version 6.1.0. https://github.com/OpenAPITools/openapi-generator/pull/10573
We have a lot of interfaces implemented by classes with @RestController and without @RequestMapping. When adding @RequestMapping to the interface they no longer work.
Please, could we add a property to disable this new behavior? In this PR it has been added to take into account that it is not used for feign.
How do you see it? @cachescrubber @welshm @MelleD @atextor @manedev79 @javisst @borsch @Zomzog @wing328
I have the same problem with @RequestMapping("${openapi.myProject.base-path:}") on annotated interfaces on version 7.8.0 of openapi-generator-maven-plugin
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api/openapi.yaml</inputSpec>
<generatorName>spring</generatorName>
<configOptions>
<sourceFolder>src/main/java</sourceFolder>
<dateLibrary>java8</dateLibrary>
<library>spring-boot</library>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<modelPackage>mkpw.blablatwo.model</modelPackage>
<apiPackage>mkpw.blablatwo.api</apiPackage>
<invokerPackage>mkpw.blablatwo.api</invokerPackage>
<serializableModel>false</serializableModel>
<useTags>true</useTags>
<useGzipFeature>true</useGzipFeature>
<hateoas>true</hateoas>
<unhandledException>true</unhandledException>
<useSpringBoot3>true</useSpringBoot3>
<requestMappingMode>none</requestMappingMode>
<useSwaggerUI>true</useSwaggerUI>
<importMappings>
<importMapping>ResourceSupport=org.springframework.hateoas.RepresentationModel</importMapping>
<importMapping>Link=org.springframework.hateoas.Link</importMapping>
</importMappings>
<ignoreFileOverride>${project.basedir}/src/main/resources/api/.openapi-generator-ignore</ignoreFileOverride>
<interfaceOnly>true</interfaceOnly>
</configOptions>
<output>${project.build.directory}/openapi-code-blaBlaTwo</output>
<supportingFilesToGenerate>
ApiUtil.java
</supportingFilesToGenerate>
<generateModels>true</generateModels>
<generateApis>true</generateApis>
</configuration>
</execution>
</executions>
</plugin>
Description
When generating Java/Spring, since 6.1.0 a @RequestMapping annotation is added to every controller type, that contains a property with a supposed default value.
See
{{=<% %>=}} @RequestMapping("${openapi.<%title%>.base-path:<%>defaultBasePath%>}") <%={{ }}=%>
The annotation contains a property expression, that is not resolvable from spring-hateoas, which breaks any hateoas application by creating broken self links like 'http://localhost:8080/${openapi.myProjectName.base-path}/', as the property is not resolved.
In our case
(Also, we assume the > char in
>defaultBasePath
is a typo?)OpenAPI declaration file content or url
any API will do as the annotation is added unconditionally
Generation Details
using maven plugin with the following config:
openapi-generator version
6.1.0, 6.2.0
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/13488
Suggest a fix
make it possible to opt out of @RequestMapping annotation generation.