-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Behavior of allowEmptyValue: false
#3792
Comments
We discussed in TSC and decided that since the use isn't recommended, we might try to continue as if this field does not exist. |
After thinking on this more, the only interpretation I can come up with that makes sense to me is:
It just doesn't make sense to me that the default would contradict how schemas work everywhere else. So it must be that the non-default value is the one that contradicts the schema. This would also parallel how In the absence of anyone knowing how this was supposed to work, that's what I'm going to explain in the text. |
I think that Visualization & try-out tools REALLY SHOULD render such a check box if (and only if) the parameter's schema accepts the empty string. And the OAS editors REALLY SHOULD remove this thingy in future versions of the specification 😄 |
@ralfhandl The UI hint makes a little more sense, but would require different wording to clarify that intent. But I'm not convinced of this interpretation either. What difference does it make to an API whether Is this about HTML's notion of what controls are successful, which defers whether to send an input that "lacks a value" or not to the implementation? (referencing HTML 4.0.1 because I can't be bothered to decipher WHATWG's pseudocode). And again, how does that impact APIs? Are APIs expected to mimic web forms, in which case there's no difference, or is this a web-form-only thing, in which case why is it in the spec at all when many other web-form-related things are not? If this is a UI hint, then I'll need to update the PR to say so. |
The question is how many different meanings an API sees in these three requests: GET /foo
GET /foo?bar
GET /foo?bar= Do absence (1) and presence (2, 3) of Do presence of If an API author intends to have three different meanings, how do they express their intent in OpenAPI? With Then things get murky.
So authors could express that forms (2) and (3) are allowed, but it was unclear how to distinguish (2) and (3). Explicit mentioning of form (2) was taken away in OpenAPI 3.0.0, see here for the TSC's rationale. Which leaves me puzzled why the keyword remained, instead of removing it and relying on My take:
|
I agree |
@ralfhandl no one's trying to "fix" this right now, I'm just trying to document what it does. We're definitely all puzzled, and it was already agreed that it should be removed. But it is still here for now, and as written it appears to require contradicting |
I'm afraid it does different things with/to different tools, and I definitely am unable to decide which of these is "right". |
I assume we'll keep this open until we've forward-ported to 3.1.x and 3.2.x |
@lornajane yes that's how I've been tracking/closing issues with PRs for multiple branches. |
PRs merged, closing! |
TL;DR: I have no idea how to define compliance criteria for
allowEmptyValue: false
, which is the default behavior, with settingtrue
being NOT RECOMMENDED.<rant>
The clarification added in 3.0.2 just says using it is NOT RECOMMENDED, which would, AFAICT, leave the default
false
behavior in place. Looking at the issue regarding that clarification, there is a lot there that never made it into the spec. Some of that says that setting it totrue
allows the undefined value behavior already defined by RFC6570.However,
style
,explode
, andallowReseved
already control the RFC6570 behavior. Are we by default forbidding empty values? Does that mean RFC6570's undefined values (which includesnull
, empty arrays, empty objects, and objects where all properties arenull
, but NOT the empty string)? Does it impact the empty string as well? Ifschema
allows these does the defaultallowEmptyValue: false
behavior contradict that? How are implementations expected to support this?If using
content
, doesallowEmptyValue
have meaning? What if thecontent
is legitimately a zero-length string?This seems like a field with a default value that blocks common cases in a very non-obvious way, requiring complex code to work around the normal behavior of Schema Objects, Media Type Objects, and RFC6570. Do we really expect implementations to enforce this? If we are recommending against its use, how do we expect users to support empty values, which can easily happen by accident (particularly empty arrays)?
</rant>
The text was updated successfully, but these errors were encountered: