OpenAPITools / OpenAPITools/openapi-generator

[Spring-Cloud] Add fallback at Feign Client

Open
#1,396 1 comment 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

We have the following Situation:
We generate a Feign Client with the OpenAPI-Generator. This produces following Code:

import org.springframework.cloud.openfeign.FeignClient;
import org.openapitools.configuration.ClientConfiguration;

@FeignClient(name="${test.name:test}", url="${test.url:https://test/abc/v1}", configuration = ClientConfiguration.class)
public interface ApiClient extends Api {
}

In the Feign client it is possible to set a fallback class which is executed when the external System is not reachable. This would look like this:

import org.springframework.cloud.openfeign.FeignClient;
import org.openapitools.configuration.ClientConfiguration;

@FeignClient(name="${test.name:test}", url="${test.url:https://test/abc/v1}", configuration = ClientConfiguration.class, fallback = TestFallback.class)
public interface ApiClient extends Api {
}

I couldn't find any configuration to set the fallback class.

openapi-generator version
<version>3.3.1</version>
OpenAPI declaration file content or url

/

Command line used for generation

/

Steps to reproduce

/

Related issues/PRs

/

Suggest a fix/enhancement

https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache

Please add ",fallback = ClientFallback.class" to the FeignClient annotation and "import {{fallback.package}}.ClientFallback".

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

Start with the JavaSpring spring-cloud template named in the issue: modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache. Read how the FeignClient annotation and imports are generated, then trace the available generator configuration for a fallback package and class. Done means the generated annotation can include the fallback and its import without breaking existing generation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.