Coder Social home page Coder Social logo

Comments (6)

quarkus-bot avatar quarkus-bot commented on August 16, 2024

/cc @cescoffier (rest-client), @geoand (jackson,rest-client), @gsmet (jackson), @maxandersen (jbang), @quarkusio/devtools (jbang)

from quarkus.

mschorsch avatar mschorsch commented on August 16, 2024

As far as i know Quarkus supports only JAX-B for XML serialisation/deserialisation.

Maybe you could write your own MessageBodyWriter / MessageBodyReader (https://quarkus.io/guides/rest#readers-and-writers-mapping-entities-and-http-bodies). I know it works for Quarkus-REST, for the REST-Client i am not sure.

from quarkus.

lecogiteur avatar lecogiteur commented on August 16, 2024

Yes, it's for rest service not for client.

In fact I find a workaround

package com.client;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import io.quarkus.rest.client.reactive.jackson.ClientObjectMapper;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import java.io.IOException;
import java.io.InputStream;

import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;

@Path("/api")
@RegisterRestClient(configKey = "my-api")
public interface CustomRestClient {

    @GET
    @Consumes("application/xml")
    InputStream get();

    default MyXmlObject get2() throws IOException {
         final ObjectMapper mapper = XmlMapper.builder()
                        .configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
                        .build();
         return mapper.readValue(get(), MyXmlObject.class);
    }
}

In my case I need only one call, so I can create mapper directly in get 2.
I use extension quarkus-rest-client not quarkus-rest-client-jackson.

But I think it's a bug. Normally we should use extension quarkus-rest-client-jackson and configure the ObjectMapper like we want. It seems there are some restrictions on media type. But Jackson can serialize and deserialize multiple data format

from quarkus.

geoand avatar geoand commented on August 16, 2024

Thanks for reporting this.

I'll say right off the bat, that I do not consider this a bug. The quarkus-rest-client-jackson extension is only meant to handle json (one could argue that the name could be better, but that's not going to change).

It is absolutely possible to use other formats, but you need to handle add your own MessageBodyReader and MessageBodyWriter implementations.

from quarkus.

lecogiteur avatar lecogiteur commented on August 16, 2024

It's a shame to limit this lib to the json format, given that Jackson manages several of them. If it's not a bug, it could be an enhancement or a name change of lib.

Thanks for the feedback.

from quarkus.

geoand avatar geoand commented on August 16, 2024

it could be an enhancement or a name change of lib.

Right, we should consider this

from quarkus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.