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

refs #2079 - JsonView support (includes and replaces #2662) #2681

Merged
merged 3 commits into from Feb 23, 2018

Conversation

frantuma
Copy link
Member

refs #2079 - JsonView support. Includes and replaces #2662 implementing ignoreJsonView field in @ApiOperation (for backward compatibility) and adding minor fixes and tests.

p4ali and others added 3 commits February 22, 2018 11:02
See original request #2079

The patch will create various definition models for response based on the original model, plus
the JsonView, e.g., given the original model Car, and JsonView named Detail and Summary, the
definition model could be Car_Summary, Car_Detail, or Car_Summary-or-Detail.

The patch also support the inheritance of the JsonView, e.g., The Detail is a subtype of Summary,
so any type/field annotated by Summary, should be visible to Detail view.

Please refer to the JsonViewTest.java for detail.
Also refer to the CarResource.java and the updated ApiListingResourceIT.java
@frantuma frantuma merged commit bb31a0f into master Feb 23, 2018
@frantuma frantuma deleted the ticket-2079 branch March 27, 2018 14:20
@webron webron mentioned this pull request Apr 21, 2018
@simenflatby
Copy link
Contributor

@frantuma I'm not getting this to work for request objects, only response objects. Is it not supported for request objects, or am I doing something wrong?

Works:

@GET
@Path("{id}")
@JsonView(Views.ProductReadSecure.class)
public ProductDTO getProduct(@PathParam("id") Integer id) {
    ProductDTO testProduct = new ProductDTO();
    testProduct.setId(id);

    return testProduct;
}

Don't work:

@POST
public Response createProduct(@JsonView(Views.ProductCreateSecure.class) ProductDTO product) {
    return Response.noContent()
            .build();
}

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

Successfully merging this pull request may close these issues.

None yet

3 participants