Skip to content
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

nullable is problematic for query and path parameters #1915

Closed
mkistler opened this issue May 2, 2019 · 4 comments
Closed

nullable is problematic for query and path parameters #1915

mkistler opened this issue May 2, 2019 · 4 comments

Comments

@mkistler
Copy link

mkistler commented May 2, 2019

I believe the nullable: true designation in the schema of a query or path parameter is problematic, or at the very least under-specified. According to the OpenAPI 3.0.2 spec, nullable: true means:

Allows sending a null value for the defined schema.

If param is a query parameter of type string that is defined as nullable: true, does ?param=null mean param is the null value or that param has the string value "null"? Or perhaps it means that users can specify ?param= with no value?

Likewise, if pet_id is a path parameter of type string that is defined as nullable: true, how would a user construct a path that specifies pet_id = null? I don't think it could be /api/pets/null. Likewise, I don't think it could be /api/pets/.

I believe the spec should be clarified to describe what it means to "send null" for a query or path parameter, or simply disallow nullable: true for these schemas.

@darrelmiller
Copy link
Member

OpenAPI V3 introduced the style parameter to provide rules for serializing parameter values. The style parameter is based on the rules of RFC 6570 and it in turn has a discussion of how to handle "undefined" values of which it considers null to be one of those values.
https://tools.ietf.org/html/rfc6570#section-3.2.1

@mkistler
Copy link
Author

mkistler commented May 2, 2019

Okay ... I should have studied up on this more. From a quick reading of RFC-6570, I see

  • null is considered "undefined".
  • If all of the variables in an expression are undefined, then the expression's expansion is the
    empty string.

So for a nullable: true query parameter whose value is null, this should be passed as ?param=.

And for a nullable: true path parameter whose value is null, this should be serialized as an empty path segment, e.g /v1/foo//bar.

Is this a correct reading of that standard and how it should be applied for query and path parameters?

@handrews
Copy link
Member

I'm not sure, https://tools.ietf.org/html/rfc6570#section-3.2.8 makes it look like the parameter is omitted? But I'm having a bit of trouble understanding what, if any, difference there is between a special null undef None value vs there simply being no mapping of that parameter at all, so 🤷‍♂

@MikeRalphson
Copy link
Member

nullable has gone away in OAS 3.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants