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

Switching to JSON-B Annotations & JSON-P breaks binding query parameters To POJO #401

Open
ckapop opened this issue Mar 16, 2023 · 0 comments

Comments

@ckapop
Copy link

ckapop commented Mar 16, 2023

Expected Behavior

Starting with this example project micronaut-jpa-hibernate-maven-java and switching from Jackson Annotations & Jackson Core to JSON-B Annotations & JSON-P in accordance with Micronaut Serialization a controller call that looks like this

@Get(value = "/list{?args*}")
List<Genre> list(@Valid SortingAndOrderArguments args) {
        return genreRepository.findAll(args);
}

Should return a valid response when calling curl http://localhost:8080/genres/list?sort=name

Actual Behaviour

Instead, the following response is returned:

{"message":"Bad Request","_links":{"self":[{"href":"/genres/list?sort=name","templated":false}]},"_embedded":{"errors":[{"message":"Failed to convert argument [args] for value [null] due to: Cannot deserialize String sort due to: Not a string","path":"/args"}]}}

Steps To Reproduce

  1. Started with the Micronaut example application: micronaut-jpa-hibernate-maven-java
  2. Switched from Jackson Annotations & Jackson Core to JSON-B Annotations & JSON-P in accordance with Micronaut Serialization
  3. Making calls that use query parameters fail to deserialize: curl http://localhost:8080/genres/list?sort=name

Using maven, this works:

<dependency>
	<groupId>io.micronaut</groupId>
	<artifactId>micronaut-runtime</artifactId>
	<scope>compile</scope>
	<exclusions>
		<exclusion>
			<groupId>io.micronaut</groupId>
			<artifactId>micronaut-jackson-databind</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
	<groupId>io.micronaut.serde</groupId>
	<artifactId>micronaut-serde-jackson</artifactId>
	<scope>compile</scope>
</dependency>

and this does not work:

<dependency>
	<groupId>io.micronaut</groupId>
	<artifactId>micronaut-runtime</artifactId>
	<scope>compile</scope>
	<exclusions>
		<exclusion>
			<groupId>io.micronaut</groupId>
			<artifactId>micronaut-jackson-databind</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
	<groupId>io.micronaut.serde</groupId>
	<artifactId>micronaut-serde-jsonp</artifactId>
	<version>1.5.2</version>
	<scope>compile</scope>
</dependency>
<dependency>
	<groupId>jakarta.json.bind</groupId>
	<artifactId>jakarta.json.bind-api</artifactId>
	<version>2.0.0</version>
	<scope>compile</scope>
</dependency>

Environment Information

OS: Microsoft Windows 10
JAVA: openjdk version "13.0.2" 2020-01-14

Example Application

https://github.com/ckapop/micronaut-jpa-hibernate-maven-java-jsonp-jsonb

Version

3.8.4

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

No branches or pull requests

1 participant