Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQ][java rest-assured] support for jackson #3570

Closed
jmini opened this issue Aug 6, 2019 · 4 comments · Fixed by #3795
Closed

[REQ][java rest-assured] support for jackson #3570

jmini opened this issue Aug 6, 2019 · 4 comments · Fixed by #3795

Comments

@jmini
Copy link
Member

jmini commented Aug 6, 2019

For the moment the java rest-assured is configured to use gson.

In some scenario using Jackson instead of gson is required. Rest-assured supports both serialization library:

REST Assured supports mapping Java objects to and from JSON and XML. For JSON you need to have either Jackson, Jackson2, Gson or Johnzon in the classpath and for XML you need JAXB.
(..)
It will first try to use Jackson if found in classpath and if not Gson will be used.

See https://github.com/rest-assured/rest-assured/wiki/Usage#object-mapping


The rest-assured templates can be extend to support either jackson or gson (current default).

@jmini
Copy link
Member Author

jmini commented Aug 6, 2019

I have prepared the patch on the branch: issue3570-restassured-jackson.

The templates are correct (we have patch the templates in the openapi-generator version we are using), but this need some work before doing a PR.

As discussed with @jimschubert on Slack, instead of adding a new library rest-assured-jackson (which will only create confusion for the users), he suggested that a new option "serialization library" could be introduced. Values can be gson or jackson for now.
Some java-client generators already supports both (code guarded with following switches: {#gson}..{/gson} and {#jackson}..{/jackson}).
With my PR rest-assured will be the next on that list. If one library (jersey2, feign
retrofit2, resttemplate, webclient, resteasy, vertx, google-api-client) works only with one library, then this setting will be ignored.

We have already this kind of behavior with the dateLibrary option. Or also the java version flag (the value is ignored for some library).

@jmini
Copy link
Member Author

jmini commented Aug 7, 2019

Also open in this issue, jackson needs to be properly configured in Rest-Assured.
This is not done yet on the issue3570-restassured-jackson branch.

For example we are interested in the disabling the AUTO_DETECT_ features as described in
#3573 for the jersey 2 client

@jmini
Copy link
Member Author

jmini commented Aug 26, 2019

Part one submitted as PR #3759: this adds the serializationLibrary option.

@jmini
Copy link
Member Author

jmini commented Aug 29, 2019

Implemented as PR #3795

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant