Requirement: I have a POST method which takes the input JSON as a String and passes it to another microservice. I don't want to create an Object (Bean) of this input JSON.
method:
@ApiOperation(notes = "example" value = "/example", consumes = ".." , method= "..")
@RequestMapping(name = "xxx" value ="/hello" ..)
@ApiResponses(..)
public @ResponseBody String getXXX (@Apiparam(name="JSONrequest", required = true) @RequestBody String JSONrequest){
}
Problem: The generated Swagger doesn't show the input as a JSON model where all the JSON attributes are displayed.
Expectation: I want to display my Swagger Something like this :
Definately I am missing the key thing. Any thoughts?
If changing from String
to a concrete object is not okay (although that's what I would recommend you to do since it's cleaner), you can try using @ApiImplicitParams
(check out their documentation)
@ApiOperation(notes = "example" value = "/example", consumes = ".." , method= "..")
@ApiImplicitParams({
@ApiImplicitParam(name = "Object", value = "Object to be created", required = true, dataType = "your.package.BodyClass", paramType = "body")
})
@RequestMapping(name = "xxx" value ="/hello" ..)
@ApiResponses(..)
public @ResponseBody String getXXX (@Apiparam(name="JSONrequest", required = true) @RequestBody String JSONrequest){
}
(not sure if you still need the @Apiparam(name="JSONrequest", required = true)
bit from the method parameter)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With