Skip to content

Configuration Reference ​

All properties live under the coapi prefix and are bound by the Spring Boot starter (CoApiProperties).

Global properties ​

PropertyDefaultDescription
coapi.enabledtruefalse turns off Spring Boot auto-configuration (classpath scanning and coapi.* binding). Clients listed in @EnableCoApi are still registered.
coapi.modeAUTOREACTIVE (WebClient), SYNC (RestClient) or AUTO (inferred from the classpath). Case-insensitive; an invalid value fails startup. See Client Modes.
coapi.base-packagesemptyExtra packages to scan for @CoApi interfaces, in addition to the @SpringBootApplication package. Accepts a comma-separated string or a YAML list.

Per-client properties ​

<name> is the client name: @CoApi(name) if set, otherwise the interface's simple name (GitHubApiClient). Renaming the client changes its configuration key.

PropertyDefaultDescription
coapi.clients.<name>.base-urlunsetReplaces the annotation's base URL. An lb:// URL enables load balancing.
coapi.clients.<name>.load-balancedunsettrue or false forces load balancing on or off.
coapi.clients.<name>.reactive.filter.namesemptyBean names of ExchangeFilterFunctions to add (reactive mode).
coapi.clients.<name>.reactive.filter.typesemptyBean types (fully qualified class names) of ExchangeFilterFunctions to add.
coapi.clients.<name>.sync.interceptor.namesemptyBean names of ClientHttpRequestInterceptors to add (sync mode).
coapi.clients.<name>.sync.interceptor.typesemptyBean types of ClientHttpRequestInterceptors to add.

Filters and interceptors must be beans. They are applied by name first, then by type, each in the configured order. A type must resolve to exactly one bean. Only the list for the active mode is used: reactive.* in reactive mode, sync.* in sync mode.

Override rules ​

The annotation defines a client. Per-client properties override it when the HTTP client is built. The result is the client's effective definition, which is also what builder customizers receive.

Base URL

  1. coapi.clients.<name>.base-url, if not blank.
  2. Otherwise @CoApi(baseUrl), with placeholders resolved.
  3. Otherwise lb:// + @CoApi(serviceId).
  4. Otherwise empty. The client must then pass a full URI per request (see Defining Clients).

An lb:// scheme (case-insensitive) is always rewritten to http:// and marks the client load balanced.

Load balancing

load-balancedbase-urlLoad balanced?
true / falseanythe configured value
unsetsetonly if it is an lb:// URL
unsetunsetas the annotation says: serviceId, an lb:// baseUrl, or @LoadBalanced

These rules are implemented in one place, CoApiDefinition.withOverrides(), and covered by ClientPropertiesTest.

Example ​

yaml
coapi:
  mode: SYNC
  base-packages:
    - com.example.partner.clients
  clients:
    # Point a load-balanced client at a fixed host in this environment
    OrderClient:
      base-url: http://orders.staging.internal:8080
    # Supply the URL of a client declared as plain @CoApi
    PaymentClient:
      base-url: https://payments.example.com
      sync:
        interceptor:
          names:
            - paymentAuthInterceptor

Without Spring Boot ​

The coapi.clients.* properties are a Spring Boot feature. In plain Spring, the same settings come from optional beans that you implement:

BeanProvides
ClientPropertiesgetBaseUri(name), getLoadBalanced(name)
ReactiveClientPropertiesgetFilter(name)
SyncClientPropertiesgetInterceptor(name)

Each one is optional: if it is missing, the client keeps exactly what its annotation declares. With Spring Boot, CoApiProperties implements all three. coapi.mode is read from the Environment in both cases.