You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation Huma is strict about unexpected fields:
By default, Huma is strict about which fields are allowed in an object, making use of the additionalProperties: false JSON Schema setting. This means if a client sends a field that is not defined in the schema, the request will be rejected with an error. This can help to prevent typos and other issues and is recommended for most APIs.
However, this does not currently apply to query parameters. Any additional query parameters are silently discarded. For example, here is the example from the tutorial where I changed name to be a query parameter:
@baderj thanks for the feature request! I think this is a good idea. Some things to keep in mind:
There may be valid use-cases of additional query params, e.g. allowing auth mechanisms other than an Authorization header or things tacked on by tools for tracking purposes.
We may need to keep the default behavior as it is now to prevent breaking people, allowing you to opt-in to the more strict behavior.
I'm happy to review a PR for this if someone wants to try and make one, otherwise I can take a look at doing it sometime soon.
According to the documentation Huma is strict about unexpected fields:
However, this does not currently apply to query parameters. Any additional query parameters are silently discarded. For example, here is the example from the tutorial where I changed
name
to be a query parameter:If the API is requested with a misspelled query parameter (
firstname
instead ofname
), then no error is returned:It would be nice to have the option to be strict about unexpected query parameters and return an error in these cases.
The text was updated successfully, but these errors were encountered: