-
Notifications
You must be signed in to change notification settings - Fork 89
Description
From a suggestion by @mikekistler :
Another signficant change from 3.0 to 3.1 was in the readOnly
and writeOnly
keywords. In OpenAPI 3.0 readOnly
is defined as:
Relevant only for Schema Object properties definitions. Declares the property as “read only”. This means that it MAY be sent as part of a response but SHOULD NOT be sent as part of the request. If the property is marked as readOnly being true and is in the required list, the required will take effect on the response only. A property MUST NOT be marked as both readOnly and writeOnly being true. Default value is false.
and writeOnly
is defined as:
Relevant only for Schema Object properties definitions. Declares the property as “write only”. Therefore, it MAY be sent as part of a request but SHOULD NOT be sent as part of the response. If the property is marked as writeOnly being true and is in the required list, the required will take effect on the request only. A property MUST NOT be marked as both readOnly and writeOnly being true. Default value is false.
In 3.1, this behavior changes (incompatibly), as describe in
https://spec.openapis.org/oas/v3.1.1.html#validating-readonly-and-writeonly
In particular, the special treatment of readOnly
or writeOnly
with required
in 3.0 is made optional in 3.1, so validation may fail for some objects in OpenAPI 3.1 where it succeed in 3.0.
I think some mention of this change should be made somewhere in this document.