connexion icon indicating copy to clipboard operation
connexion copied to clipboard

Add support for 'content' in path & query parameters

Open UmakantKulkarni opened this issue 4 years ago • 7 comments

Let say, if my YAML looks like this:

/pets/{petId}:
    get:
      parameters:
        - name: petId
          in: path
          required: true
          content:
            application/json:
             schema:
               $ref: 'individualSchema.yaml#/components/schemas/PetId'
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object

Here, petId is a content of type application/json. So, while starting flask server, I was getting following error :

File "/usr/lib/python3/openapi/connexion/operations/openapi.py", line 212, in get_path_parameter_types
    path_schema = path_defn["schema"]
KeyError: 'schema'

To avoid this error, I propose the fix as per this checkin/pull request, where we should look for content if schema is not present under parameters.

Fixes # - Enhancement

Changes proposed in this pull request:

  • Add support for content in path parameters
  • Add support for content in query parameters

UmakantKulkarni avatar Apr 07 '20 04:04 UmakantKulkarni

Coverage Status

Coverage decreased (-0.4%) to 95.877% when pulling 0b003e9e037b96f0c062385b2f871b39aef1fd83 on UmakantKulkarni:master into 818a259a7213c05a9301179bd62cc7a13d806744 on zalando:master.

coveralls avatar Apr 07 '20 04:04 coveralls

This also fixes the issue mentioned here - https://github.com/zalando/connexion/issues/746

UmakantKulkarni avatar Apr 22 '20 23:04 UmakantKulkarni

Can you link the relevant OpenAPI spec and add tests?

hjacobs avatar Apr 25 '20 14:04 hjacobs

Can you link the relevant OpenAPI spec and add tests?

@hjacobs, Can you please point me to the file/location in this repository where I need to add tests and sample openapi schema, Thanks.!

UmakantKulkarni avatar Apr 26 '20 02:04 UmakantKulkarni

Can you link the relevant OpenAPI spec and add tests? OpenAPI spec can be found here and says "For more complex scenarios, the content property can define the media type and schema of the parameter. A parameter MUST contain either a schema property, or a content property, but not both."

I am running into the same issue (where I wish to pass in a free-form mapping as one single parameter) and this PR can be helpful. I can add tests if @UmakantKulkarni is not available.

xiaoyu-wu avatar Jul 30 '20 00:07 xiaoyu-wu

@hjacobs @jmcs would the maintainers please give suggestions how to get this PR merged?

xiaoyu-wu avatar Aug 10 '20 02:08 xiaoyu-wu

Why is this not merged? If you need some "relevant" spec that use this feature you have the 5G SBI spec, defined by 3GPP: https://github.com/jdegre/5GC_APIs/

Sincasios avatar Aug 23 '22 17:08 Sincasios

Outdated.

RobbeSneyders avatar Nov 02 '23 14:11 RobbeSneyders