Virat
Virat

Reputation: 581

Swagger in my spring boot application

What is paramType in the annotation

 @ApiImplicitParams( {
 @ApiImplicitParam( name = RestRequestHeader.XAUTHTOKEN, value = RestRequestHeader.VALUE, required = RestRequestHeader.REQUIRED, dataType = "string", paramType = "header" ) } )

What are the different values paramType can take and what are its functionalities? I have tried searching in google, but could not find any satisfying solution.

Upvotes: 1

Views: 1064

Answers (2)

Samarth
Samarth

Reputation: 773

You can check out OpenAPI specification.

Possible values are "path", "query", "body", "header", "form"

Note that the values MUST be lower case.

  • path paramtype suggests that the type of implicitparam goes into requestUri

  • query means it is a type of url query params

  • body denotes it should be read from request body (payload)

  • header denotes the parameters coming in request header

  • form denotes field corresponds to the form parameter.

UPDATE

Basically what you are saying is correct you can use form or query also in case of GET method. But according to OpenAPI specs if your parameter type is File, the consumes field MUST be multipart/form-data, and the paramType MUST be form. form should be used also when content-type is application/x-www-form-urlencoded

For path you can use if your RequestParam mappings looks something like @RequestMapping("/test/{id}") here you can use path as your paramType to define id param. In this case your url will contain dynamic values lets say

For e.g. a url https://stackoverflow.com/posts/43342169/edit contains (43342169) which is post id going as param in url itself these type of params are path param.

Upvotes: 0

Related Questions