杰客网络

杰客网络个人博客

@ApiImplicitParam注解的dataType、paramType两个属性的区别?

Java 0 评

dataType="int" 代表请求参数类型为int类型,当然也可以是Map、User、String等;

paramType="body" 代表参数应该放在请求的什么地方:

header-->放在请求头。请求参数的获取:@RequestHeader(代码中接收注解)
query-->用于get请求的参数拼接。请求参数的获取:@RequestParam(代码中接收注解)
path(用于restful接口)-->请求参数的获取:@PathVariable(代码中接收注解)
body-->放在请求体。请求参数的获取:@RequestBody(代码中接收注解)
form(不常用)

https://swagger.io/docs/specification/describing-parameters/

Parameter Types
OpenAPI 3.0 distinguishes between the following parameter types based on the parameter location. The location is determined by the parameter’s in key, for example, in: query or in: path.

path parameters, such as /users/{id}
query parameters, such as /users?role=admin
header parameters, such as X-MyHeader: Value
cookie parameters, which are passed in the Cookie header, such as Cookie: debug=0; csrftoken=BUSe35dohU3O1MZvDCU

docker 镜像制作