-
-
Notifications
You must be signed in to change notification settings - Fork 780
Description
Description
I use multipart/form-data with a property bar which is of type array. The encoding is set to application/json. The spec looks like this:
openapi: 3.0.3
info:
title: LIQUID Dataset Service
version: 1.0.0
paths:
/foo:
post:
x-openapi-router-controller: liquid_dataset_service.controllers.dataset_controller
operationId: create_bar
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
bar:
type: array
items:
type: object
properties:
baz:
type: string
required:
- bar
encoding:
bar:
contentType: application/json
responses:
204:
description: No ContentExpected behaviour
When running the request I'd expect to get the bar property passed into the body argument of my controller function.
Actual behaviour
Server raises error: Validation error: '["{\\n \\"baz\\": \\"string\\"\\n}"]' is not of type 'object' - 'bar.0'.
To me it looks like that the string is not properly parsed if it's an array. To verify I changed the type of bar from array of object's to array of string's:
bar:
type: array
items:
type: stringI passed two strings "one" and "two" and received this dict in my controller function: {'bar': ['["one"', '"two"]']}.
Steps to reproduce
Create a controller function, e.g.:
def create_bar(body):
return
Adjust property x-openapi-router-controller accordingly.
Fire up the swagger page or use curl to run the request.
Additional info:
Output of the commands:
python --version: Python 3.11.6pip show connexion | grep "^Version\:": Version: 3.0.5