Clash when required=false and readOnly=true in @ApiModelProperty

542 views
Skip to first unread message

Henrik Helmø Larsen

unread,
Apr 6, 2016, 5:06:49 AM4/6/16
to Swagger
I am not quite sure if this is a bug:
If I set a field to "readOnly" - I would not expect the swagger documentation page to display "optional". See below screenshots


And here is the swagger @ApiModelProperty specifications for the above lines:


@ApiModelProperty(value = "End timestamp of the resource", readOnly = true)
protected Date versionEnd = endDate;
@ApiModelProperty(value = "The reviewId of the resource - ...", required = true)
protected String reviewId;
@ApiModelProperty(value = "NoteId of the resource. Points to a note resource", readOnly = true)
protected Long noteId;
@ApiModelProperty(value = "UserPK of the person that edited the resource", readOnly = true)
protected String createdBy;
@ApiModelProperty(value = "The system that has edited the resource", readOnly = true)
protected String createdByClientId;
@ApiModelProperty(value = "UserPK of the person that has deleted the resource (if it is deleted)", readOnly = true)
protected String deletedBy;
@ApiModelProperty(value = "The system that has deleted the resource (if it is deleted)", readOnly = true)
protected String deletedByClientId;

tony tam

unread,
Apr 6, 2016, 9:22:35 AM4/6/16
to swagger-sw...@googlegroups.com
Read-only and “required" are different, please take a look at the javadocs here:


I do agree that some indication that a field is read only should be in the UI.  Could you please open an issue for that on the swagger-ui repo?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Henrik Helmø Larsen

unread,
Apr 7, 2016, 3:58:56 AM4/7/16
to Swagger
I totally agree that "read-only" and required are different.

My point is that when a field is "read-only" - then it makes no sense to render "optional" in the UI - as my guess that "read-only" means that "this field cannot be set by user - it is a server-side provided field".

Reply all
Reply to author
Forward
0 new messages