Forum Discussion

priyapitaliya's avatar
priyapitaliya
New Contributor
5 years ago

Swagger UI, @ApiResponse doesn't give correct response as a examle value.

I have implemented swagger UI in my application. Everything is working fine but the issue is,
consider the situation in my API I have different request and response object, but both object's class is annotated with the same json root element name (Ex: @JsonRootName("user")).
For this reason in my swagger UI it gives me same example value in Parameters body and in Responses body. If i remove this @JsonRootName tag from any one class than swagger UI shows me correct example value, but for my application i can't remove this annotation from any class and even can't change the value of it.
I tried many option available on internet but can't resolve my problem. Please help me to resolve this.
Please refer the attached screens.

 

Thanks, Waiting for your response.

7 Replies

  • Can you provide the openapi.json or swagger.json you get from your application?

      • RonRatovsky's avatar
        RonRatovsky
        Moderator

        If I follow everything you shared correctly, it looks like that by overriding the JSON model name, you end up having two separate objects with the same name, and one ends up canceling the other when it's translated to the definition. You'd have to give the models a distinct name, otherwise it'll keep happening.