Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger Example Post Body From Annotations

Does anyone know if it's possible to create an example post body with pre-populated/default values from Java annotations? My goal is for users to have a working example when viewing a POST endpoint in Swagger UI. Ideally this working example is created from annotations in the code.

For Example on a model object property:

    @ApiModelProperty(example = "http://istock.com/my_cool_image")
    @JsonProperty("submitted-image-url")
    private String submittedImageUrl;

Would produce something like this in Swagger UI (note the example URL shows up in the Model Schema):

enter image description here

like image 218
Fabian Avatar asked Apr 07 '26 09:04

Fabian


1 Answers

The way it appears to be designed, you have to click on Example Value under Data Type for the request/Value textarea to be populated (at least in Swagger 1.5.9).

like image 57
KirEvse Avatar answered Apr 09 '26 22:04

KirEvse