Encoding
This class defines the encoding rules for a single property within a request body, specifying how the property should be serialized. It supports configurations for content types, custom headers, and serialization styles, including options for exploding arrays and allowing reserved characters. This model is typically used to describe complex data structures in OpenAPI specifications.
Attributes
| Attribute | Type | Description |
|---|---|---|
| contentType | string = null | The Content-Type for encoding a specific property, such as application/json or image/png. |
| headers | dict = null | A map of headers that provides additional metadata for the specific property being encoded. |
| style | string = null | Describes how the parameter value will be serialized, determining the format of the encoded data. |
| explode | boolean = null | Specifies whether arrays and objects should generate separate parameters for each element or property. |
| allowReserved | boolean = null | Determines whether reserved characters in the parameter value are allowed to be sent without percent-encoding. |
Constructor
Signature
def Encoding(
contentType: str | None = None,
headers: dict[str, Union["Header", [Reference](reference.md?sid=fastapi_openapi_models_reference)]]| None = None,
style: str | None = None,
explode: bool | None = None,
allowReserved: bool | None = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| contentType | `str | None` = None |
| headers | `dict[str, Union["Header", Reference]] | None` = None |
| style | `str | None` = None |
| explode | `bool | None` = None |
| allowReserved | `bool | None` = None |
Methods
contentType()
def contentType() - > string
The Content-Type for encoding a specific property, such as application/json or image/png.
Returns
| Type | Description |
|---|---|
string | The media type string or null if not specified. |
headers()
def headers() - > dict
A map of headers relative to the encoding property, allowing for custom header definitions in the response.
Returns
| Type | Description |
|---|---|
dict | A dictionary mapping header names to Header objects or References. |
style()
def style() - > string
Describes how the parameter value will be serialized depending on the type of the parameter value.
Returns
| Type | Description |
|---|---|
string | The serialization style identifier. |
explode()
def explode() - > boolean
Determines whether arrays and objects should generate separate parameters for each element or property.
Returns
| Type | Description |
|---|---|
boolean | True if the parameter should be exploded into multiple values. |
allowReserved()
def allowReserved() - > boolean
Determines whether the parameter value should allow reserved characters as defined by RFC3986 to be included without percent-encoding.
Returns
| Type | Description |
|---|---|
boolean | True if reserved characters are permitted in the encoded value. |