JacksonJsonDecoder has a list of mime types including APPLICATION_NDJSON.
But the ReactiveTypeHandler (used on the server side) has WILDCARD_SUBTYPE_SUFFIXED_BY_NDJSON so it supports a wider range of media types. Ideally they would be the same.
A workaround is to just use application/x-ndjson on the server. Or to replace the default JSON decoder on the client side:
@BeforeEach
void setUp(@Autowired WebClient.Builder builder, @LocalServerPort int port) {
this.rest = builder.codecs(config -> {
MimeType[] mimeTypes = new MimeType[] {
MediaType.APPLICATION_JSON,
new MediaType("application", "*+json"),
MediaType.APPLICATION_NDJSON,
MediaType.valueOf("application/*+x-ndjson")
};
JacksonJsonDecoder decoder = new JacksonJsonDecoder(JsonMapper.builder(), mimeTypes);
config.defaultCodecs().jacksonJsonDecoder(decoder);
}).baseUrl("http://localhost:" + port).build();
}
JacksonJsonDecoderhas a list of mime types includingAPPLICATION_NDJSON.But the
ReactiveTypeHandler(used on the server side) hasWILDCARD_SUBTYPE_SUFFIXED_BY_NDJSONso it supports a wider range of media types. Ideally they would be the same.A workaround is to just use
application/x-ndjsonon the server. Or to replace the default JSON decoder on the client side: