我使用Swagger ui和Swagger core(1.3)进行平针织应用 . 我有一些查询参数,我必须发送每个请求,如post,get,delete ...
我怎么能默认这个?
您可以使用Swagger注释中的注释 @ApiParam 来配置要从Swagger-UI使用的查询参数 .
@ApiParam
例如
@Path("/{username}") @ApiOperation(value = "Updated user") public Response updateUser( @ApiParam(value = "description for query-parameter") @QueryParam("username") String username ) { ... }
请在以下官方文档中阅读有关此注释的更多信息:https://github.com/swagger-api/swagger-core/wiki/Annotations#apiparam
你可以知道swagger-code / swagger-ui是否支持这个,你可以定义parameters to be reuse across operations .
例如 :
{ "parameters": { "pageParam": { "name": "page", "in": "query", "description": "page number to get", "required": false, "type": "integer", "format": "int32" } }, "paths": { "/customers": { "get": { "description": "Retrive list of customers", "parameters": { "$ref": "#/parameters/pageParam" }, ... } } }, ... }
2 回答
您可以使用Swagger注释中的注释
@ApiParam
来配置要从Swagger-UI使用的查询参数 .例如
请在以下官方文档中阅读有关此注释的更多信息:https://github.com/swagger-api/swagger-core/wiki/Annotations#apiparam
你可以知道swagger-code / swagger-ui是否支持这个,你可以定义parameters to be reuse across operations .
例如 :