Skip to content

Conversation

@roidelapluie
Copy link

Previously, Huma was hardcoded to look for the validation schema in RequestBody.Content["application/json"]. This caused validation to fail when operations only specified other content types like application/cbor or application/x-www-form-urlencoded.

This commit makes the schema lookup more flexible:

  1. First try application/json for backwards compatibility
  2. If not found, fall back to the first available content type with a schema

This allows operations to use contentType tags to specify non-JSON request bodies while still benefiting from Huma's validation.

Previously, Huma was hardcoded to look for the validation schema in
RequestBody.Content["application/json"]. This caused validation to
fail when operations only specified other content types like
application/cbor or application/x-www-form-urlencoded.

This commit makes the schema lookup more flexible:
1. First try application/json for backwards compatibility
2. If not found, fall back to the first available content type with a schema

This allows operations to use contentType tags to specify non-JSON
request bodies while still benefiting from Huma's validation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant