Open jonjanisch opened 9 months ago
Could you provide a small Maven reproducer? That will be easier for us to reproduce. Thanks!
/cc @FroMage (resteasy-reactive), @geoand (resteasy-reactive), @stuartwdouglas (resteasy-reactive)
I've attached the maven project to the original description above. Let me know if you need anything else! Thanks. P.S. Ignore the weird indentation in GreetingResource, I removed indentation to copy the code into github! 🙂
Interesting use case for sure. I don't have a lot of time these days, but I'll try to address it at some point.
@geoand Thank you! Of course we're not using it to hide password that's just example code.
Or did you mean usage of sub-resource? If it's the latter I'm curious. I would have imagined most non-trivial use cases are using sub-resources. We have around 100 resource classes currently with only a single root resource that delegates to smaller resources as we're primarily using Quarkus to build an app and not for microservices.
I meant the sub-resources
code-with-quarkus.zip
Describe the bug
We want to use
@JsonView
to to selectively hide/show fields for different scenarios.It works for the simple scenario of adding it to a top-level Resource. But the same code fails if the endpoint is in a sub-resource.
Example
Basic User class where we want to hide the
password
field in the JSON response except for Private.The Views are identical to https://quarkus.io/guides/resteasy-reactive#jsonview-support
Create a simple endpoint at the top-level and it works fine.
Bug Scenario - using
@JsonView
in Sub-ResourceNow create another class
BugResource
with the same code and inGreetingResource
add a method to return the sub-resource:Temporary workaround
Our current workaround is to inject ObjectMapper and manually serialize to a String but it gets pretty ugly as we add
@JsonView
to more endpoints:Expected behavior
@JsonView
annotation on endpoints should work regardless if endpoint is top-level resource or sub-resource.Actual behavior
@JsonView
annotation does not work in sub-resources.How to Reproduce?
quarkus-resteasy-reactive-jackson
dependency to pom.xml@GET
endpoint with a@JsonView
annotation.Add User.java and Views.java
Same as documentation:
Open browser:
http://localhost:8080/hello/bug
Output of
uname -a
orver
No response
Output of
java -version
No response
Quarkus version or git rev
3.5.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
Bug has existed since at least 2.16.6.Final. I was hoping the upgrade to 3.5.1 would fix it.