-
Notifications
You must be signed in to change notification settings - Fork 89
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
Despite having the JsonView specified, the openAPI response is resulting with all the objects of the entity #1724
Comments
Hi @VarunReddy1111 , if you can provide a simple project that demonstrates the issue, that will help us find the problem. |
Thank you for the response @MikeEdgar , below is code that demonstrates the issue
I am using quarkus 3.5.0. When I go to swagger page, I see the endpoints of different methods, whenever I expand the endpoint, I see a Example value Schema section, where I am getting all the objects of the class and all of its attributes in super class instead of only retrieving the attributes which were specified with View class in JsonView annotation. In the above code, I have CarEntity with 3 attributes, each having view class specified in JsonView annotation and in the BaseIdCrudInterface, the JsonView specifies only ReadView class. But the response schema is having all the attributes of the class as in the below image. The project I am working consists of a lot of nested classes, where the example value schema section is resulting in large json, leading to freeze and crashing of the page. Below is the image illustrating the issue. Sample project displaying this behaviour: https://gitlab.com/nilosedge/inheritance/-/tree/Swagger-Issue?ref_type=heads OpenAPI Yaml file:
|
The response object has a @Data
@Schema(name = "ObjectResponce", description = "POJO that represents the ObjectResponce")
public class ObjectResponce<E extends BaseEntity> {
@JsonView(View.ReadView.class)
private E entity;
} |
The below is the View class for above example:
I have also tried removing/changing the annotations( |
This is a sample project displaying this behaviour: https://gitlab.com/nilosedge/inheritance/-/tree/Swagger-Issue?ref_type=heads . Please let me know if you need any other inputs. |
@VarunReddy1111 , the problem is that the annotation scanner is using the Lombok generated un-annotated methods rather than the field. You can work around it like with something like this until it's fixed: @Getter(onMethod=@__({@JsonView(View.ReadView.class)}))
@Setter(onMethod=@__({@JsonView(View.ReadView.class)})) |
Thanks for above resolution @MikeEdgar . Currently, we have another issue, which is crashing of swagger page due to large response bodies, do you have any solutions for such kind of issues like having a save/download button or limiting the size or truncating the response? |
@VarunReddy1111 , I'm not sure about that. You might find a solution in the swagger-ui project though. https://github.com/swagger-api/swagger-ui |
Having specified with different view classes in JsonView annotation while doing a Rest API call, the openAPI response is containing all the objects of the entity, instead of just the provided JsonViews leading to a nested object structure and resulting a big json file. Also, causing the swagger page to freeze and crash when expanding the APIs.
openapi.txt
The text was updated successfully, but these errors were encountered: