question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[REQ] Java MicroPofile Rest client with Jackson serialization?

See original GitHub issue

Is your feature request related to a problem? Please describe.

Quarkus, an up-and-coming Java Microprofile implementation will soon allow users to use JAX-RS with Jackson, instead of the standard JSONB as discussed here

Currently this generator cannot generate Microprofile rest client code based on JAX-RS+jackson code. I tried this (in my Gradle):

   ...
    openApiGenerate {
        generatorName = "java"       
        configOptions = [
                dateLibrary: "java8",
                java8: "true",
                library:"microprofile",
                serializationLibrary:"jackson"
        ]
     
    }

but the generated code is still JAX-RS/JSONB, not JAX-RS/Jackson

Describe the solution you’d like

This should do the trick:

 openApiGenerate {
        generatorName = "java"       
        configOptions = [
                ...
                library:"microprofile",
                serializationLibrary:"jackson"
        ]

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
najibkcommented, Apr 28, 2021

It would be nice to address this 6 month old issue. is there any way to use jackson with microprofile rest client ?

2reactions
plevartcommented, Jan 25, 2022

Unfortunately in this case, the generated code has a dependency on Swagger-Annotations instead of Microprofile-Annotations.

So it would be nice if the generator for microprofile would support using Jackson instead of JSONB (which currently is very frustrating when you want to use Java 17 records)

The API classes (interfaces) are generated for “microprofile” client, so they are annotated with microprofile (RegisterProvider, RegisterRestClient) and JAX-RS (Path, GET, POST, …) annotations. Generated classes also specify a wildcard include for org.apache.cxf.jaxrs.ext.multipart.*, but I’ve never seen any annotation used from that package, so I specify the dependency as “optional”. These are the dependencies I use in such maven API module:

        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.microprofile.rest.client</groupId>
            <artifactId>microprofile-rest-client-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            <optional>true</optional>
        </dependency>

The model classes get a mix of Jackson, Swagger and Findbugs (jsr305) annotations. In runtime, only Jackson annotations are needed so other dependencies can be specified as “optional” in pom.xml If you can do without them at runtime (you are not using Swagger GUI for example), and they won’t be included in the app. I use the following in pom.xml for such maven model module:

        <dependency>
           <groupId>com.fasterxml.jackson.core</groupId>
           <artifactId>jackson-annotations</artifactId>
       </dependency>

       <dependency>
           <groupId>io.swagger</groupId>
           <artifactId>swagger-annotations</artifactId>
           <optional>true</optional>
       </dependency>

       <dependency>
           <groupId>com.google.code.findbugs</groupId>
           <artifactId>jsr305</artifactId>
       </dependency>

Are there any other annotations you would like to be present? Where? In the API or model classes?

I agree that it would be nice to have proper support for microprofile/Jackson combo so these workarounds would not be necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set representation for specific format on Json Serializer ...
1. First, you need to enable Jackson, as RESTEasy defaults to JSONB. For this you need to add this system property: resteasy.
Read more >
Using the REST Client - Quarkus
The MicroProfile REST client allows amending request headers by registering a ClientHeadersFactory with the @RegisterClientHeaders annotation. Let's see it in ...
Read more >
MicroProfile Rest Client and JSON-B make working ... - Medium
JSON-B, one of the many flavors of working with JSON, allows very quick and very simple serialization and deserialization of Java objects. For ......
Read more >
Configuring the MicroProfile Rest Client - IBM
The MicroProfile Rest Client builds on the JAX-RS 2.0 Client APIs to provide a type-safe approach to invoke RESTful services over HTTP. You...
Read more >
RESTEasy JAX-RS - JBoss.org
MicroProfile Rest Client ... org.jboss.resteasy.resteasy-jackson-provider ... with WildFly and completely integrated as per the requirements of Java EE.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found