Header
Declare a header parameter for a path operation. Header parameters are extracted from HTTP request headers.Signature
Parameters
Default value if the parameter field is not set.
Automatically convert underscores to hyphens in the parameter field name. For example,
user_agent becomes user-agent.An alternative name for the parameter field. This will be used to extract the data and for the generated OpenAPI.
Human-readable title for the parameter.
Human-readable description for the parameter.
Greater than validation. If set, the value must be greater than this. Only applicable to numbers.
Greater than or equal validation. If set, the value must be greater than or equal to this. Only applicable to numbers.
Less than validation. If set, the value must be less than this. Only applicable to numbers.
Less than or equal validation. If set, the value must be less than or equal to this. Only applicable to numbers.
Minimum length for strings.
Maximum length for strings.
RegEx pattern for strings.
Parameter field name for discriminating the type in a tagged union.
If True, strict validation is applied to the field.
Value must be a multiple of this. Only applicable to numbers.
Allow
inf, -inf, nan. Only applicable to numbers.Maximum number of allowed digits for numbers.
Maximum number of decimal places allowed for numbers.
Example values for this field.
Mark this parameter field as deprecated. It will affect the generated OpenAPI (visible at
/docs).Whether to include this parameter field in the generated OpenAPI.
Any additional JSON schema data.
Examples
Basic Header Parameter
By default,
user_agent will automatically be converted to User-Agent when reading from headers due to convert_underscores=True.Disable Automatic Conversion
Required Header
A header parameter is required when there is no default value.
Multiple Header Values
This allows receiving multiple headers with the same name. For example, multiple
X-Token headers.Header with Validation
Custom Header Name with Alias
Use
alias when you want to use a different variable name in Python than the actual header name.