Differences from Spring

spring_boot_starter_feign follows Spring Cloud OpenFeign: the same annotation, mapping annotations, property keys, exceptions, Retryer.Default and interceptors. This page lists where it does not, and why.

Why

When you port a Spring client, you need to know where the behaviour is not the one you expect. Most differences come from Dart (asynchronous HTTP, no reflection) and from the fact that Spring Cloud's infrastructure (service discovery, load balancing, circuit breakers) does not exist here.

Example

@FeignClient('catalog', url: r'${catalog.url}')
abstract interface class CatalogClient {
  @GetMapping('/books/{isbn}')
  Future<Book> find(@PathVariable() String isbn);
}
@EnableFeignClients
@SpringBootApplication
class ShopApplication {}

@FeignClient(name = "catalog", url = "${catalog.url}")
interface CatalogClient {
  @GetMapping("/books/{isbn}")
  Book find(@PathVariable String isbn);
}

Setup and configuration

Spring Cloud OpenFeign Here Why
@EnableFeignClients not needed The starter is enough.
spring.cloud.openfeign.* spring.feign.*; the old name stops the start Spring Cloud means nothing in Dart.
Service discovery and load balancing by name every client needs a URL There is no discovery client.
connect-timeout per client under default only One shared transport.
Only connect and read timeouts per attempt call-timeout and the caller's RequestDeadline bound the whole call A call should never outlive its request.
retryer, error-decoder, request-interceptors name classes Spring creates they name beans, by bean name or a class name matching exactly one bean No reflection.
Configuration classes in child contexts ordinary @Configuration() beans kept away from the other clients; only Retryer, ErrorDecoder and RequestInterceptor are per client Dart cannot create a class by reflection.
<contextId>FeignClient alias none; primary and qualifiers are read by the generator

Requests

Feign Here Why
Synchronous methods Futures, or EventStream<T> HTTP is asynchronous in Dart.
Accept sent only for produces Accept: application/json by default (text/event-stream for streams) Most APIs are JSON.
Spaces in query parameters as %20 as + (form encoding)
A @PathVariable value . or .. sent as is ArgumentError Dart's Uri removes such segments, so the call would go to another path.
One query map and one header map per method several Map parameters allowed
Interceptors run again on the same template at a retry each retry starts from a new template Header values would pile up.
feign-form's @FormProperty the ObjectMapper's names (@JsonProperty); a nested object fails with EncodeException
Streaming multipart built in memory; a list of plain values is one text field per item
No streaming server-sent events with EventStream<T> and reconnection

Errors, fallbacks and logs

Spring Cloud OpenFeign Here
Fallback through a circuit breaker, FallbackFactory The fallback answers every failure, a 404 too, after the retries; no circuit breaker, no FallbackFactory yet.
Feign's logger masks nothing Authorization, Proxy-Authorization, Cookie, Set-Cookie, DPoP and sensitive-headers are masked.
Logger named after the interface's qualified name feign.<Interface>.

Not supported yet

See also