Plug module for validating Accept headers against response content types.
This plug validates that the client's Accept header matches at least one of the content types defined in the OpenAPI schema's response section.
init options
[available_types, operation_id]where
available_typesis a list of media type strings from the response content definition, andoperation_idis the operation identifier.
Behavior
- If no Accept header is present, the request passes (RFC 7231: client accepts any)
- If Accept header is
*/*, the request passes - If any accepted type matches an available type (including wildcards), passes
- If no match found, raises
Apical.Exceptions.NotAcceptableError(406)
Quality factors
Accept headers with quality factors (q=X) are supported:
- Types with q=0 are excluded from matching
- Other quality values are used for preference ordering (but any match passes)
Summary
Functions
Checks if any of the accepted types matches any of the available types.
Extracts all content types from all responses of an operation.
Parses an Accept header into a list of {type, subtype, params, quality} tuples.
Functions
Checks if any of the accepted types matches any of the available types.
Handles wildcards:
*/*matches anythingtype/*matches any subtype of that type
Extracts all content types from all responses of an operation.
Looks at the responses object and collects content types from all response codes.
Parses an Accept header into a list of {type, subtype, params, quality} tuples.
Types with q=0 are filtered out as they explicitly reject that type.