connexion
connexion copied to clipboard
Add support for 'content' in path & query parameters
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
Coverage decreased (-0.4%) to 95.877% when pulling 0b003e9e037b96f0c062385b2f871b39aef1fd83 on UmakantKulkarni:master into 818a259a7213c05a9301179bd62cc7a13d806744 on zalando:master.
This also fixes the issue mentioned here - https://github.com/zalando/connexion/issues/746
Can you link the relevant OpenAPI spec and add tests?
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.!
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.
@hjacobs @jmcs would the maintainers please give suggestions how to get this PR merged?
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/
Outdated.