Spring / Swagger-UI - 当用户点击 "Try it out" 按钮时在请求模型中显示实际值的示例
Spring / Swagger-UI - Show example of real values in request model when user clicks on "Try it out" button
如何让 swagger-ui 在下面的示例框中显示预先填充的实际值? (用户在 swagger 中单击“试用”按钮时显示的请求模型框 -ui)。
我正在使用 SpringBoot/Java,我希望它显示一些实际值而不是数据类型。默认情况下,它会为 DOB 字段执行此操作。
我已将 MyModel
定义如下,我期望在 ApiModelProperty
中使用“value
”将设置这些值,但它不是:
@ApiModel(description="blahblah")
public class MyModel {
@ApiModelProperty(notes = "some notes", name = "name", required = true, value = "Bot")
private String name;
@ApiModelProperty(notes = "Date of birth", name = "dob", required = true)
private OffsetDateTime dob;
@ApiModelProperty(notes="How old", name = "age", required = true, value = "31")
private Integer age;
...
}
我希望上面看起来像:
使用example
:
@ApiModelProperty(notes = "some notes", name = "name", required = true, example = "Bot")
private String name;
如何让 swagger-ui 在下面的示例框中显示预先填充的实际值? (用户在 swagger 中单击“试用”按钮时显示的请求模型框 -ui)。
我正在使用 SpringBoot/Java,我希望它显示一些实际值而不是数据类型。默认情况下,它会为 DOB 字段执行此操作。
我已将 MyModel
定义如下,我期望在 ApiModelProperty
中使用“value
”将设置这些值,但它不是:
@ApiModel(description="blahblah")
public class MyModel {
@ApiModelProperty(notes = "some notes", name = "name", required = true, value = "Bot")
private String name;
@ApiModelProperty(notes = "Date of birth", name = "dob", required = true)
private OffsetDateTime dob;
@ApiModelProperty(notes="How old", name = "age", required = true, value = "31")
private Integer age;
...
}
我希望上面看起来像:
使用example
:
@ApiModelProperty(notes = "some notes", name = "name", required = true, example = "Bot")
private String name;