Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Params by plug convention should contain merged path, body and query parameters #588

Closed
hamir-suspect opened this issue Jan 3, 2024 · 1 comment · Fixed by #589
Closed

Comments

@hamir-suspect
Copy link
Contributor

According to Plug documentation conn.params is

the request params, the result of merging the :path_params on top of :body_params on top of :query_params

When using OpenApiSpex.Plug.CastAndValidate plug the params will overwrite only with params from :path | :query | :header | :cookie meaning that there is never parameters from request_body there.

This should be clearly stated in CastAndValidate plug like it is for cast plug as it can cause some confusion.

@mbuhot
Copy link
Collaborator

mbuhot commented May 12, 2024

The library was initially implemented with all params merged into conn.params as per the docs. Unfortunately it is problematic with struct based body schemas.

If your body schema is a struct, the adding additional query params creates a struct with undeclared fields set. It technically works since structs are just maps, but it is confusing and may cause type errors in future elixir versions.

@mbuhot mbuhot closed this as completed May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants