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

query params of type object with style: form are not being deserialized #1291

Open
Halkcyon opened this issue Sep 8, 2020 · 3 comments
Open
Labels

Comments

@Halkcyon
Copy link

Halkcyon commented Sep 8, 2020

Description

When defining objects to take through a query string, they are not being deserialized in my app code. The function parameter is being passed an empty dict, but request.form definitely sees the proper values.

Expected behaviour

The params are deserialized into a dict and passed into my view.

Actual behaviour

The params show up on request.form, but are not being deserialized; I receive an empty dict for the key defined in my spec.

Steps to reproduce

openapi: 3.0.3
info:
  title: REST API
  version: 1.0.0
servers:
  - url: /api/v1
paths:
  /:
    get:
      parameters:
        - name: page
          in: query
          schema:
            type: object
            required:
              - pageNo
              - pageSize
            properties:
              pageNo:
                type: number
              pageSize:
                type: number
        - name: location
          in: query
          schema:
            type: object
            properties:
              street:
                type: string
              city:
                type: string

Additional info:

Output of the commands:

  • python --version

      Python 3.7.0
    
  • pip show connexion | grep "^Version\:"

      connexion 2.7.0
    
@RobbeSneyders
Copy link
Member

Thanks for the report @Halkcyon.

Connexion currently doesn't deserialize query objects with style: form correctly, which is the default. If you control the client, you can work around this by using style: deepObject instead. More info on the style values in the openapi docs.

@RobbeSneyders
Copy link
Member

Related to #963

@RobbeSneyders RobbeSneyders changed the title query params of type object are not being deserialized query params of type object with style: form are not being deserialized Apr 13, 2023
@Oduig
Copy link

Oduig commented Dec 4, 2024

Thanks for the report @Halkcyon.

Connexion currently doesn't deserialize query objects with style: form correctly, which is the default. If you control the client, you can work around this by using style: deepObject instead. More info on the style values in the openapi docs.

Since it's a pretty old thread, but it's still open, @RobbeSneyders is this still a bug in Connexion 3?

An example, we'd like to specify query parameters like this:

      parameters:
        - in: query
          name: query
          style: form
          explode: true
          schema:
            $ref: './schemas/users.yaml#User'

This would auto-include any User property and make it possible to define query filters on any User field. This way, we don't have to re-define each user property as an individual query parameter. With strict validation, Connexion does not respect this specification and rejects all query parameters.

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

No branches or pull requests

3 participants