-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
immutable
keyword
#31
Comments
I think You just need to have more than one schema. E.g. one for creating entity, and second for getting it and updating it. (I think schema for getting and updating can be usually the same) |
Additionally, you can also mark an object as read-only. {
"type": "object",
"properties": {
...
},
"readOnly": true
} This, to me, says that the entire object is immutable. Since |
I am sympathetic to this issue, although I'm not sure what the right solution is. The problem IMO is that |
JSON schema has
readOnly
andwriteOnly
to specify static read/write access to a property but sometimes it's useful to have immutable properties that can only be written once and only read thereafter.For example a
POST
request could accept a value (property actswriteOnly
) and for subsequent request the property actsreadOnly
similar to immutable variables in many programming languages.I think a
immutable
keyword would be a useful meta-data addition that validators can generally ignore unless they have knowledge whether the validated data is considered "new" in which case it could fail validation when it's not new and a value for an immutable property is present.The text was updated successfully, but these errors were encountered: