-
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
Form with omissible field member #34
Comments
Ah, good catch! The So for a resulting Form Submission Object (FSO), it seems like a field can be:
Given 4 possible states, it seems that two booleans would work:
Thoughts? |
Actually on second thought, I think |
Hi. If I get a list of fields that I am supposed to provide to perform some action (REST service) I would expect them to be required if nothing else is said. Do not know If the analogy is good enough but if I read a recipe when cooking something I expect the ingredients to be required if nothing else is written... :) |
Hrm - I think For example, consider a user creation endpoint, e.g.
it doesn't make sense in this case that all of these would be required by default. Indeed, most could be optional during creation (except maybe password and email or username), and in update, practically all are optional. I think that's why HTML and SQL take the optional-by-default/required-is-explicit stance. I believe most data in heterogeneous systems is optional (or very nearly close to 50/50, with a slight edge to optional), which is why I think Does this make sense? Was I able to convince you? ;) Thoughts? |
P.S. I'm slightly in favor of a @dogeared @nbarbettini @fosrias @smizell any thoughts about this? |
In XSD the minOccurs for an element is 1 by default meaning you have to set minOccurs=0 to make the element optional. RAML defaults to required = true for parameters. OpenAPI/Swagger defaults to required = false. One thing to consider is the context of the client developers/API users. If they are used to work with SOAP or RAML it is maybe more intuitive with required = true as default but as such developers may be just as familiar with OpenAPI/Swagger this does not help me sorting out what should be the best default value... So from my point of view the important thing is the default value is specified - true or false may just be a matter of taste :) |
I think that |
Hi @lhazlewood.
I miss the possibility to declare a Form Field Member as possible to omit when submitting a Form. This can be useful in for example a CRUD update scenario where semantics of setting a Member value to null would overwrite (3) persisted Member value with the null value while omitting the field when submitting the form would not affect the persisted Member value at all (2). (Or if complying with RFC 7396 - delete the persisted Field Member when Field Member in request is null)
In other words I want to be able to specify one Form where both 2 and 3 below are valid Form Submission Objects.
Scenario:
1:
PUT /person/1
{"name": "Peter", "age": 10} -> persisted Resource={"name": "Peter", "age": 10}
2:
PATCH /person/1
{"age": 11} -> persisted Resource={"name": "Peter", "age": 11}
3:
PATCH /person/1
{"name": null, "age": 12} -> persisted Resource={"name": null, "age": 12}
There are ways around this to accomplish almost the same thing. As I understand it I can for example use the 'mutable' Form Field Member and resend the Field Member value as it was persisted (with extra data on the wire as a consequence).
Please correct me if I have missed something but from my point of view this is something that should be possible to express in the form.
What are your thoughts on this?
The text was updated successfully, but these errors were encountered: