spec-first/connexion

Automatically assign default values on requests

Opened this issue · 2 comments

From the docs:

Connexion will not automatically pass in the default values defined in your requestBody definition, but you can activate this by configuring a different RequestBodyValidator.

That sounds like a design decision. May I asked why this decision was made?

If it's just not implemented yet, would you be open for a PR?

Hi @alfechner,

This is indeed a conscious decision. The reason not to do this by default, is because it requires us to intercept the request body in middleware, modify it, and replay it to the application. This can lead to some issues, such as oom due to loading binary files in the body into memory.

We do provide an implementation which should work for most applications, and which is explained on the page the snippet you quoted links to. I would be better to link to this section directly though, so I would be happy with a PR to update this in the docs.

I understand, thanks for explaining.

Wouldn't it make sense to have it enabled for json media types, though? The binary oom issue would only apply to binary type I guess. Form data would read the files into memory anyway (remember this discussion?)