Skip to content

Configuration properties for Jackson JsonMapper per service interface client group #50304

@eduardog3000

Description

@eduardog3000

I would like to configure my service client's JsonMapper separately from the application as a whole. Right now I can do that programmatically:

@Bean
RestClientHttpServiceGroupConfigurer groupConfigurer() {
    var jsonMapper = JsonMapper.builder()
        .enable(ACCEPT_CASE_INSENSITIVE_ENUMS)
        .enable(ACCEPT_SINGLE_VALUE_AS_ARRAY)
        // etc.
        .build();
    var converter = new JacksonJsonHttpMessageConverter(jsonMapper);
    
    return groups -> {
        groups.filterByName("abc").forEachClient((_, builder) -> {
            builder.configureMessageConverters(client -> {
                client.withJsonConverter(converter);
            });
        });
    };
}

But I would like if it could be done with a configuration property:

spring:
  http:
    serviceclient:
      abc:
        jackson: # the same properties as spring.jackson
          mapper:
            accept-case-insensitive-enums: true
          deserialization:
            accept-single-value-as-array: true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions