I am trying to setup swagger for my rest api
In response when I mention custom response type in ApiResponse Like
@ApiResponse(code = 200, message = "Success", response = Entity.class)
I am getting example output, but when I do
@ApiParam(value = "start year", required = true, name = "startYear")Entity startYear,
I don't get sample input body.
And it shows
Any help is appreciated.
Can you share the full method signature?
I am having the same issue.
@ApiOperation(value = "My operation")
@ApiResponses({ @ApiResponse(code = 400, message = VALIDATION_ERROR_MESSAGE, response = ValidationErrorVb.class), @ApiResponse(code = 500, message = ERROR_MESSAGE, response = ErrorVb.class) })
@RequestMapping(path = "test/{bar}", method = { RequestMethod.GET })
public Collection<Foo> getFoo(@ApiParam(value = "My bar value", example = "bar123", required = true) @PathVariable String bar)
The example "bar123" doesn't exist in the generated JSON.
By the way. I am also wondering why a @PathVariable is not required by default. I have to specify it explicitly.
Thanks for your help.
@Trialer1 you're not using swagger-core, you're using Springfox. If you have an issue with it, you should open a ticket there.
That's true. Yesterday I tried it using the Maven Swagger Plugin and it also didn't worked.
I tried it again today and now it is working. Don't know what the problem was. Thanks for your help. I will create a ticket at Springfox and until they fix it I will switch to the Maven Plugin instead of Springfox.
Okay. @maneeshbhunwal - can't really help you if you don't provide the signature, so I'll be closing the ticket for now. Feel free to reopen if relevant.
I have the same problem. I am using Swagger-annotations 1.5.10. I want to show the example input for the API as below.
@ApiParam(value = "Input for get canonical names service", required = true, examples = @Example(@ExampleProperty(value = "{\r\n\"inputs\": [{\r\n\t\"entityType\": \"type0\",\r\n\t\"token\": \"flower\"\r\n}]\r\n})))
Actually, no matter the example is what, there is no example shown in UI. But, all other attributes, e.g., value, required are displayed correctly. The only problem is the example. Is there any potential package conflicting with exampleproperty?
Any help will be appreciated!
Same problem with 1.5.17
Same issue with 1.5.16.
Any updates on here?
Same problem with latest, 1.5.18
@ApiParam(value = "Printer config in json format", required = false, examples = @Example(value = @ExampleProperty(mediaType = MediaType.APPLICATION_JSON, value = ApiDocuExamples.PRINTER_CONFIG)))
@FormParam("config") String configJson,
@ApiParam(value = "Id of an existing printer config", required = false, example = ApiDocuExamples.PRINTER_CONFIG_ID)
@FormParam("configId") Integer configId)
example and examples not working.
If I open my swagger.json in editor.swagger.io it will be displayed.
Why this issue was closed? Imho the issue still exists.
Hey even for me @ApiImplicitParam attribute example and examples are not showing up in swagger UI. Did anyone found solution for above issue?
@dominicE @JessieGit Is it working for you guys?
Thanks Much!
Can confirm, still not working -.-"
Doesn't work, still closed!
Does not work for me too
The issue was closed as the OP did not provide the required details. If you still experience the issue, please file a new ticket.
Not working for me too.
As per this thread it should work for path and query parameters (not body parameters), but still no luck.
defaultValue from @RequestParam could be used as workaround. But for me example and examples don't work too.
@ApiParam(name="inputXml", value="input") InputTag input
Here InputTag is a java pojo class annotated as xml element:
@XmlRootElement(name = "input")
public class InputTag{
private string tag1;
private string tag2;
setters and getters should be like
@XmlElement(name = "tag1")
public String getTag1() {
return tag1;
}
@XmlElement(name = "tag2")
public String getTag2() {
return tag2;
}
}
My input xml looks like :
<input>
<tag1>string</tag1>
<tag2>string</tag2>
</input>
Most helpful comment
Why this issue was closed? Imho the issue still exists.