connexion icon indicating copy to clipboard operation
connexion copied to clipboard

Using nullable or x-nullable for deepObject parameter properties not supported?

Open psauxgrep opened this issue 3 years ago • 2 comments

Description

I have a deepObject query parameter called filter. This filter parameter has two different properties: id and name:

… 
paths:
  /people:
    get:
      operationId: api.get_names
      parameters:
        - name: filter
          style: deepObject
          explode: true
          schema:
            additionalProperties: false
            type: object
            properties:
              id:
                type: integer
	        x-nullable
                nullable: true
             name:
                type: string
…

I want to accept nullable properties (so not the string 'null' but the actual value null) for the id property, like this:

curl --request GET --url 'http://localhost:5000/people?filter[id]=null'

From what I understand the x-nullable and nullable defined in OpenAPI 3.0 properties support this.

When sending this request however, I would expect to retrieve a Python filter dictionary looking as follows: {"id" : None}. However I get a connexion error stating the following: 'null' is not of type 'integer'.

I came across this post where someone states that x-nullable (and I assume therefore nullable itself) works at the parameter level but not within an object. Is this still the case?

I've also tried modifying my type property as follows:

  properties:
              id:
                type:
                   - integer
                   - 'null'

But this gives me an error when starting the server saying that the scheme cannot be validated (makes sense).

Is there another way to pass null values via a deepObject property that will be converted to None in my server?

Expected behaviour

A Python dictionary looking as follows: {"id" : None}

Actual behaviour

A connexion error stating the following: 'null' is not of type 'integer'.

Steps to reproduce

See above

Additional info:

Output of the commands:

  • python --version : 3.9.1
  • pip show connexion | grep "^Version\:" 2.9.0

psauxgrep avatar Mar 25 '22 13:03 psauxgrep

Thanks for the report @psauxgrep. Can reproduce.

RobbeSneyders avatar Apr 01 '22 15:04 RobbeSneyders