You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'll try to explain my problem as clearly as possible...
We have numerous endpoints in our system that specify the same @RequestBody object and essentially we would like to provide example json requests to each specific endpoint. The request object itself has fields we wish to exclude in some cases and not in others. Ideally I am looking to annotate our Spring Rest controller methods each with an exact json string which would show as a useful visual for the user in the swagger UI.
Lets say I have a Request object class that represents our object for multiple endpoints:
public class PrepRequest{
String name;
String type;
Location location;
Destination destinaton;
}
If I have two different endpoints that both receive the PrepRequest above - for the first one I want the example to show on swagger UI as let's say:
{
'name' : 'A',
'type' : 'search'
}
and for the second endpoint I would like to display the example json to the user as:
This is just a super basic example - I hope it makes sense but we basically need to modify the example json per endpoint so that the user will know which style of request to provide.
I have seen in numerous places the possibility of using @ApiImplicitParams just above the controller endpoint method or by tagging the request body parameter as @ApiParam(examples = @example(...
But in both cases I cannot seem to get the example json window of swagger to actually show what I would like to see...in all cases it seems to give me the full requestBody object and all of it's fields.
Is there a way to tag per controller endpoint or at the Api parameter level - the exact json I want to show to the end user in swagger as an example?
The text was updated successfully, but these errors were encountered:
I'll try to explain my problem as clearly as possible...
We have numerous endpoints in our system that specify the same @RequestBody object and essentially we would like to provide example json requests to each specific endpoint. The request object itself has fields we wish to exclude in some cases and not in others. Ideally I am looking to annotate our Spring Rest controller methods each with an exact json string which would show as a useful visual for the user in the swagger UI.
Lets say I have a Request object class that represents our object for multiple endpoints:
If I have two different endpoints that both receive the PrepRequest above - for the first one I want the example to show on swagger UI as let's say:
and for the second endpoint I would like to display the example json to the user as:
This is just a super basic example - I hope it makes sense but we basically need to modify the example json per endpoint so that the user will know which style of request to provide.
I have seen in numerous places the possibility of using @ApiImplicitParams just above the controller endpoint method or by tagging the request body parameter as @ApiParam(examples = @example(...
But in both cases I cannot seem to get the example json window of swagger to actually show what I would like to see...in all cases it seems to give me the full requestBody object and all of it's fields.
Is there a way to tag per controller endpoint or at the Api parameter level - the exact json I want to show to the end user in swagger as an example?
The text was updated successfully, but these errors were encountered: