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

Boolean query parameter with allowEmptyValue responds 400 insisting on =true #1538

Closed
OJFord opened this issue May 12, 2022 · 3 comments
Closed

Comments

@OJFord
Copy link

OJFord commented May 12, 2022

Description

A Boolean query parameter with allowEmptyValue: true does not allow an empty (i.e. ?param) value; instead returning 400 Boolean expected.

Expected behaviour

/api/blah?allowedEmptyBooleanParam should work

Actual behaviour

{
	"detail": "Wrong type, expected 'boolean' for query parameter 'allowedEmptyBooleanParam'",
	"status": 400,
	"title": "Bad Request",
	"type": "about:blank"
}

Steps to reproduce

    allowedEmptyBooleanParam:
      name: allowedEmptyBooleanParam
      in: query
      schema:
        type: boolean
        default: false
      allowEmptyValue: true

Additional info:

Output of the commands:

  • python --version Python 3.10.4
  • pip show connexion | grep "^Version\:" Version: 2.13.0
@Ruwann Ruwann added the bug label May 13, 2022
@Ruwann
Copy link
Member

Ruwann commented Jun 2, 2022

Hi @OJFord , thanks for the report.

What would be the resulting value of this parameter in the view function? The spec/docs doesn't seem to be very clear on that:

Note: nullable is not the same as an optional parameter or an empty-valued parameter. nullable means the parameter value can be null. Specific implementations may choose to map an absent or empty-valued parameter to null, but strictly speaking these are not the same thing. Source

In addition, it seems that the behaviour was never very clear and it is now even "NOT RECOMMENDED". (OAI/OpenAPI-Specification#1573)

So, I would either:

  • label this as "won't fix", or
  • pass the parameter value of None

How does that sound to you?

@OJFord
Copy link
Author

OJFord commented Jun 2, 2022

Hm, thanks for that link. My own interpretation and attempted use was the 'name-only' use described there, that an option was false if omitted and true if ?specified (but no value). I thought this was pretty standard/common.

I suppose no need to do anything until/unless it's refined or 'recommended' again in OAS 4.0.

@RobbeSneyders
Copy link
Member

Agree with a "won't fix" based on that thread.

@RobbeSneyders RobbeSneyders closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants