custom datatype in request body for POST method

332 views
Skip to first unread message

subbu mani

unread,
Mar 22, 2017, 10:46:13 AM3/22/17
to Swagger
In Swagger 2 , we are facing below issue :

We are having a POST method, which uses query string while submitting the request. Since it is a security issue , we have used @ApiImplicitParam annotation since it is supporting 'body'  attribute. This works only for the primitive data types and does not work for the complex objects (Custom Object) . Is there anyway custom object with POST method?

tony tam

unread,
Mar 22, 2017, 12:05:51 PM3/22/17
to swagger-sw...@googlegroups.com
You’ll need to share some more details.  Post some code for best feedback.

On Mar 22, 2017, at 7:46 AM, subbu mani <subbu...@gmail.com> wrote:

In Swagger 2 , we are facing below issue :

We are having a POST method, which uses query string while submitting the request. Since it is a security issue , we have used @ApiImplicitParam annotation since it is supporting 'body'  attribute. This works only for the primitive data types and does not work for the complex objects (Custom Object) . Is there anyway custom object with POST method?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dinesh PS

unread,
Mar 23, 2017, 8:41:52 AM3/23/17
to Swagger
@ApiOperation(value = "Add", notes = "Add Notes", response = Add.class)
@RequestMapping(value = "/add", method = RequestMethod.POST, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
@ApiResponses( {
@ApiResponse( code = 201, response = Add.class),  
@ApiResponse( code = 400,  response = Status.class ), 
@ApiResponse( code = 500,  ),
@ApiResponse( code = 403, )
} )
@ResponseBody
@ApiImplicitParams({@ApiImplicitParam(name = "requestID", value="Request ID", required = true, paramType = "body", dataType = "String"),
@ApiImplicitParam(name = "apiKey", required = true, paramType = "header", dataType = "String"),
@ApiImplicitParam(name = "mode", required = true, paramType = "body", dataType = "String")
})
public ResponseEntity<Object> add(HttpServletRequest request, Fee fee) {
String rqId = request.getParameter("requestID");
}
 
This is sample code we used. Here there are two primitive type params and One complex type param Fee.
The issues we are facing are

1) if we submit the request from swagger UI we are getting the values as null. for request.getParameter("requestID") which is a bdoy parameter mentioned in the paramType = "body".
2) How to handle complex Object like Fee object  in swagger UI


On Wednesday, 22 March 2017 21:35:51 UTC+5:30, tony tam wrote:
You’ll need to share some more details.  Post some code for best feedback.
On Mar 22, 2017, at 7:46 AM, subbu mani <subbu...@gmail.com> wrote:

In Swagger 2 , we are facing below issue :

We are having a POST method, which uses query string while submitting the request. Since it is a security issue , we have used @ApiImplicitParam annotation since it is supporting 'body'  attribute. This works only for the primitive data types and does not work for the complex objects (Custom Object) . Is there anyway custom object with POST method?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

tony tam

unread,
Mar 23, 2017, 12:49:59 PM3/23/17
to swagger-sw...@googlegroups.com
You need to share the swagger json file that is generated from your code for help with the swagger ui question.  Can you paste it in here?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages