更新时间:2023-09-18 13:56:16
您可以将应在响应中显示但在请求中不显示的属性的readOnly属性设置为true.
You can set the readOnly attribute to true for the properties which should be shown in the response, but not in the request.
private Integer rate;
@ApiModelProperty(readOnly = true)
private String user;
@ApiModelProperty(readOnly = true)
private Date date;
swagger-fox生成的模型将是
The model generated by swagger-fox will be
"definitions": {
"Obj": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date-time",
"readOnly": true
},
"rate": {
"type": "integer",
"format": "int32"
},
"user": {
"type": "string",
"readOnly": true
}
}
}
}
在swagger编辑器中,它将以以下方式显示.
In the swagger editor, it will be displayed in the following manner.