vitalik / django-ninja

💨 Fast, Async-ready, Openapi, type hints based framework for building APIs
https://django-ninja.dev
MIT License
6.97k stars 420 forks source link

[BUG] Openapi generated docs won't submit arrays correctly in forms. #1289

Open KonstantinosPetrakis opened 2 weeks ago

KonstantinosPetrakis commented 2 weeks ago

Greetings. There's been an issue to the problem I am referring to, which was closed for no reason to my understanding.

Essentially, when you define a Schema with a List[str] field the openapi generated documentation is not in sync with what the schema excepts.

The schema excepts a repeated value (e.g names=John&names=Jane) or through JavaScript code:

const names = ["John", "Jane"];
const form = new FormData();
for (const name of names) form.append("names", name);
// make request

But the openapi docs send a single comma separated string resulting to an array with a single item containing that string (e.g ["John, Jane"].

The documentation is supposed to work out of the box. User code checking for commas to fix that library issue shouldn't be acceptable (what if the separated string contained a comma itself?).

KonstantinosPetrakis commented 2 weeks ago

As the author of the original issue mentioned it most likely has to do something with explode:false.