Swagger ui - request parameter

I am using Swagger ui and Swagger core (1.3) for jersey application. I have certain request parameters that I have to send with every request like message, receive, delete ...

How can I do this by default?

+3


source to share


2 answers


You can use the annotation @ApiParam

from Swagger annotations to customize the request parameter to be used from the Swagger-UI.

for example



@Path("/{username}")
@ApiOperation(value = "Updated user")
public Response updateUser(
  @ApiParam(value = "description for query-parameter") @QueryParam("username") String username
) {
...
}

      

Please read more about this annotation in the following official documentation: https://github.com/swagger-api/swagger-core/wiki/Annotations#apiparam

+5


source


You can't, but since swagger 2.0 (I don't know if this is supported by swagger-code / swagger-ui), you can define parameters to be reused across different operations .

For example:



{
  "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"
        },
        ...
      }
    }
  },
  ...
}

      

0


source







All Articles