I am using Swagger ui and Swagger core (1.3) for a jersey application. I have certain query parameters which I must send with every request like post, get, delete...
How can I default this ?
Query parameters are a defined set of parameters attached to the end of a url. They are extensions of the URL that are used to help define specific content or actions based on the data being passed. To append query params to the end of a URL, a '? ' Is added followed immediately by a query parameter.
In JSON there are two ways to represent null values, first is when there is no value for a given key and its value is implicitly set to null, and second is when the key is present and its value is explicitly set to null.
As query parameters are not a fixed part of a path, they can be optional and can have default values.
You can use the annotation @ApiParam
from the Swagger annotations in order to configure the Query param 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
You can't, but since swagger 2.0 (I don't know if this is supported by swagger-code/swagger-ui), you can defines parameters to be reuse across 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"
},
...
}
}
},
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With