'How to give multiple examples for request body for POST request in Swagger2?
How we can define multiple examples for request object just like we define examples for response object as below.
@ApiResponses(value = {
@ApiResponse(code = 200, response = Response.class, message = "Success", examples = @io.swagger.annotations.Example(
value = {
@ExampleProperty(value = "{'key1': 'value1', 'key2':'value2'}", mediaType = "application/json")
}))
})
Solution 1:[1]
I couldn't find much in swagger2, but i upgraded to openapi and then given examples as below
@io.swagger.v3.oas.annotations.parameters.RequestBody(content = {
@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value = "{\"key1\": \"value1\", \"key2\":\"value2\", \"key3\":\"value3\"}"))
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
