openapi-generator: [BUG] @RequestMapping annotation not allowed on @FeignClient interfaces

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

Code generation with plugin failed with error @RequestMapping annotation not allowed on @FeignClient interfaces after update to 6.1.0

openapi-generator version

6.1.0

Generation Details

This is our configuration for the maven plugin:

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>${openapi-generator-maven-plugin.version}</version>
    <configuration>
        <configOptions>
            <dateLibrary>java8</dateLibrary>
            <disableHtmlEscaping>true</disableHtmlEscaping>
            <hateoas>false</hateoas>
            <hideGenerationTimestamp>true</hideGenerationTimestamp>
            <interfaceOnly>true</interfaceOnly>
            <sourceFolder>models</sourceFolder>
            <useTags>true</useTags>
        </configOptions>
        <generateModels>true</generateModels>
        <generatorName>spring</generatorName>
        <library>spring-cloud</library>
        <skipIfSpecIsUnchanged>true</skipIfSpecIsUnchanged>
    </configuration>
    <executions>
        <execution>
            <id>generate-api</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <apiPackage>${project.groupId}.${project.artifactId}.api.v1</apiPackage>
                <inputSpec>${project.basedir}/docs/openapi.yaml</inputSpec>
                <modelPackage>${project.groupId}.${project.artifactId}.api.v1.model</modelPackage>
                <modelNameSuffix>ApiV1</modelNameSuffix>
            </configuration>
        </execution>
    </executions>
</plugin>

In openapi-generator version < 6.1.0, the plugin generate following code:

@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "Test")
public interface TestApi {
...
}

This is the result after updating to 6.1.0+.

@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "Test")
@RequestMapping("${openapi.localServices.base-path:/test/v1}")
public interface TestApi {

We use this interface to setup the feign clients like this:

@FeignClient(name = "test",
             url = "${sdu.test.url:}",
             configuration = {TestApiConfig.class, ApiClientConfig.class})
public interface TestApiClient extends TestApi {
}
Steps to reproduce
Related issues/PRs
Suggest a fix

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 15 (12 by maintainers)

Most upvoted comments

@RomainPruvostMHH and @welshm could you please habe look and revert this change?

I can try to take a look at this today or tomorrow

Hello,

May I know when this fix would be released?

Thank you!

@RomainPruvostMHH and @welshm could you please habe look and revert this change?

The related change is probably https://github.com/OpenAPITools/openapi-generator/pull/10573 where @RequestMapping was moved from the controller to the interface.