params#

litestar.params.Body(*, const: bool | None = None, content_encoding: str | None = None, default: Any = _EmptyEnum.EMPTY, description: str | None = None, examples: list[Example] | None = None, external_docs: ExternalDocumentation | None = None, ge: float | None = None, gt: float | None = None, le: float | None = None, lt: float | None = None, max_items: int | None = None, max_length: int | None = None, media_type: str | RequestEncodingType = RequestEncodingType.JSON, min_items: int | None = None, min_length: int | None = None, multipart_form_part_limit: int | None = None, multiple_of: float | None = None, pattern: str | None = None, title: str | None = None, schema_extra: dict[str, Any] | None = None, schema_component_key: str | None = None) Any#

Create an extended request body kwarg definition.

Parameters:
  • const – A boolean flag dictating whether this parameter is a constant. If True, the value passed to the parameter must equal its default value. This also causes the OpenAPI const field to be populated with the default value.

  • content_encoding – The content encoding of the value. Applicable on to string values. See OpenAPI 3.1 for details.

  • default – A default value. If const is true, this value is required.

  • description – String value used in the description section of the OpenAPI schema for the given parameter.

  • examples – A list of Example models.

  • external_docs – A url pointing at external documentation for the given parameter.

  • ge – Constrict value to be greater or equal to a given float or int. Equivalent to minimum in the OpenAPI specification.

  • gt – Constrict value to be greater than a given float or int. Equivalent to exclusiveMinimum in the OpenAPI specification.

  • le – Constrict value to be less or equal to a given float or int. Equivalent to maximum in the OpenAPI specification.

  • lt – Constrict value to be less than a given float or int. Equivalent to exclusiveMaximum in the OpenAPI specification.

  • max_items – Constrict a set or a list to have a maximum number of items. Equivalent to maxItems in the OpenAPI specification.

  • max_length – Constrict a string or bytes value to have a maximum length. Equivalent to maxLength in the OpenAPI specification.

  • media_type – Defaults to RequestEncodingType.JSON.

  • min_items – Constrict a set or a list to have a minimum number of items. Equivalent to minItems in the OpenAPI specification.

  • min_length – Constrict a string or bytes value to have a minimum length. Equivalent to minLength in the OpenAPI specification.

  • multipart_form_part_limit – The maximal number of allowed parts in a multipart/formdata request. This limit is intended to protect from DoS attacks.

  • multiple_of – Constrict value to a multiple of a given float or int. Equivalent to multipleOf in the OpenAPI specification.

  • pattern – A string representing a regex against which the given string will be matched. Equivalent to pattern in the OpenAPI specification.

  • title – String value used in the title section of the OpenAPI schema for the given parameter.

  • schema_extra

    Extensions to the generated schema. If set, will overwrite the matching fields in the generated schema.

    Added in version 2.8.0.

  • schema_component_key – Use this as the key for the reference when creating a component for this type .. versionadded:: 2.12.0

class litestar.params.BodyKwarg#

Bases: KwargDefinition

Data container representing a request body.

__init__(examples: list[Example] | None = None, external_docs: ExternalDocumentation | None = None, content_encoding: str | None = None, default: Any = _EmptyEnum.EMPTY, title: str | None = None, description: str | None = None, const: bool | None = None, gt: float | None = None, ge: float | None = None, lt: float | None = None, le: float | None = None, multiple_of: float | None = None, min_items: int | None = None, max_items: int | None = None, min_length: int | None = None, max_length: int | None = None, pattern: str | None = None, lower_case: bool | None = None, upper_case: bool | None = None, format: str | None = None, enum: Sequence[Any] | None = None, read_only: bool | None = None, schema_extra: dict[str, Any] | None = None, schema_component_key: str | None = None, include_in_schema: bool = True, media_type: str | RequestEncodingType = RequestEncodingType.JSON, multipart_form_part_limit: int | None = None) None#
media_type: str | RequestEncodingType = 'application/json'#

Media-Type of the body.

multipart_form_part_limit: int | None = None#

The maximal number of allowed parts in a multipart/formdata request. This limit is intended to protect from DoS attacks.

__hash__() int#

Hash the dataclass in a safe way.

Returns:

A hash

class litestar.params.CookieParameter#

Bases: ParameterKwarg

Describes a cookie parameter.

In the OpenAPI, this maps to a parameter in: cookie.

param_type: ClassVar[ParamType] = 'cookie'#

Type of the parameter

litestar.params.Dependency(*, default: Any = _EmptyEnum.EMPTY, skip_validation: bool = False) Any#

Create a dependency kwarg definition.

Parameters:
  • default – A default value to use in case a dependency is not provided.

  • skip_validation – If True provided dependency values are not validated by signature model.

class litestar.params.DependencyKwarg#

Bases: object

Data container representing a dependency.

__init__(default: Any = _EmptyEnum.EMPTY, skip_validation: bool = False) None#
default: Any = 0#

A default value.

skip_validation: bool = False#

Flag dictating whether to skip validation.

__hash__() int#

Hash the dataclass in a safe way.

Returns:

A hash

litestar.params.FromCookie#

Declare a cookie parameter

alias of Annotated[T, CookieParameter(examples=None, external_docs=None, content_encoding=None, default=_EmptyEnum.EMPTY, title=None, description=None, const=None, gt=None, ge=None, lt=None, le=None, multiple_of=None, min_items=None, max_items=None, min_length=None, max_length=None, pattern=None, lower_case=None, upper_case=None, format=None, enum=None, read_only=None, schema_extra=None, schema_component_key=None, include_in_schema=True, name=None, annotation=_EmptyEnum.EMPTY, header=None, cookie=None, query=None, required=None)]

litestar.params.FromHeader#

Declare a header parameter

alias of Annotated[T, HeaderParameter(examples=None, external_docs=None, content_encoding=None, default=_EmptyEnum.EMPTY, title=None, description=None, const=None, gt=None, ge=None, lt=None, le=None, multiple_of=None, min_items=None, max_items=None, min_length=None, max_length=None, pattern=None, lower_case=None, upper_case=None, format=None, enum=None, read_only=None, schema_extra=None, schema_component_key=None, include_in_schema=True, name=None, annotation=_EmptyEnum.EMPTY, header=None, cookie=None, query=None, required=None)]

litestar.params.FromPath#

Declare a path parameter

alias of Annotated[T, PathParameter(examples=None, external_docs=None, content_encoding=None, default=_EmptyEnum.EMPTY, title=None, description=None, const=None, gt=None, ge=None, lt=None, le=None, multiple_of=None, min_items=None, max_items=None, min_length=None, max_length=None, pattern=None, lower_case=None, upper_case=None, format=None, enum=None, read_only=None, schema_extra=None, schema_component_key=None, include_in_schema=True, name=None, annotation=_EmptyEnum.EMPTY, header=None, cookie=None, query=None, required=None)]

litestar.params.FromQuery#

Declare a query parameter

alias of Annotated[T, QueryParameter(examples=None, external_docs=None, content_encoding=None, default=_EmptyEnum.EMPTY, title=None, description=None, const=None, gt=None, ge=None, lt=None, le=None, multiple_of=None, min_items=None, max_items=None, min_length=None, max_length=None, pattern=None, lower_case=None, upper_case=None, format=None, enum=None, read_only=None, schema_extra=None, schema_component_key=None, include_in_schema=True, name=None, annotation=_EmptyEnum.EMPTY, header=None, cookie=None, query=None, required=None)]

class litestar.params.HeaderParameter#

Bases: ParameterKwarg

Describes a header parameter.

In the OpenAPI, this maps to a parameter in: header.

param_type: ClassVar[ParamType] = 'header'#

Type of the parameter

class litestar.params.KwargDefinition#

Bases: object

Data container representing a constrained kwarg.

examples: list[Example] | None = None#

A list of Example models.

external_docs: ExternalDocumentation | None = None#

A url pointing at external documentation for the given parameter.

content_encoding: str | None = None#

The content encoding of the value.

Applicable on to string values. See OpenAPI 3.1 for details.

default: Any = 0#

A default value.

If const is true, this value is required.

title: str | None = None#

String value used in the title section of the OpenAPI schema for the given parameter.

description: str | None = None#

String value used in the description section of the OpenAPI schema for the given parameter.

const: bool | None = None#

A boolean flag dictating whether this parameter is a constant.

If True, the value passed to the parameter must equal its default value. This also causes the OpenAPI const field to be populated with the default value.

gt: float | None = None#

Constrict value to be greater than a given float or int.

Equivalent to exclusiveMinimum in the OpenAPI specification.

ge: float | None = None#

Constrict value to be greater or equal to a given float or int.

Equivalent to minimum in the OpenAPI specification.

lt: float | None = None#

Constrict value to be less than a given float or int.

Equivalent to exclusiveMaximum in the OpenAPI specification.

le: float | None = None#

Constrict value to be less or equal to a given float or int.

Equivalent to maximum in the OpenAPI specification.

multiple_of: float | None = None#

Constrict value to a multiple of a given float or int.

Equivalent to multipleOf in the OpenAPI specification.

min_items: int | None = None#

Constrict a set or a list to have a minimum number of items.

Equivalent to minItems in the OpenAPI specification.

max_items: int | None = None#

Constrict a set or a list to have a maximum number of items.

Equivalent to maxItems in the OpenAPI specification.

min_length: int | None = None#

Constrict a string or bytes value to have a minimum length.

Equivalent to minLength in the OpenAPI specification.

max_length: int | None = None#

Constrict a string or bytes value to have a maximum length.

Equivalent to maxLength in the OpenAPI specification.

pattern: str | None = None#

A string representing a regex against which the given string will be matched.

Equivalent to pattern in the OpenAPI specification.

lower_case: bool | None = None#

Constrict a string value to be lower case.

upper_case: bool | None = None#

Constrict a string value to be upper case.

format: str | None = None#

Specify the format to which a string value should be converted.

enum: Sequence[Any] | None = None#

A sequence of valid values.

read_only: bool | None = None#

A boolean flag dictating whether this parameter is read only.

schema_extra: dict[str, Any] | None = None#

Extensions to the generated schema.

If set, will overwrite the matching fields in the generated schema.

Added in version 2.8.0.

schema_component_key: str | None = None#

Use as the key for the reference when creating a component for this type .. versionadded:: 2.12.0

include_in_schema: bool = True#

A boolean flag dictating whether this parameter should be included in the schema. .. versionadded:: 2.17.0

property is_constrained: bool#

Return True if any of the constraints are set.

__init__(examples: list[Example] | None = None, external_docs: ExternalDocumentation | None = None, content_encoding: str | None = None, default: Any = _EmptyEnum.EMPTY, title: str | None = None, description: str | None = None, const: bool | None = None, gt: float | None = None, ge: float | None = None, lt: float | None = None, le: float | None = None, multiple_of: float | None = None, min_items: int | None = None, max_items: int | None = None, min_length: int | None = None, max_length: int | None = None, pattern: str | None = None, lower_case: bool | None = None, upper_case: bool | None = None, format: str | None = None, enum: Sequence[Any] | None = None, read_only: bool | None = None, schema_extra: dict[str, Any] | None = None, schema_component_key: str | None = None, include_in_schema: bool = True) None#
litestar.params.Parameter(annotation: Any = _EmptyEnum.EMPTY, *, const: bool | None = None, content_encoding: str | None = None, cookie: str | None = None, default: Any = _EmptyEnum.EMPTY, description: str | None = None, examples: list[Example] | None = None, external_docs: ExternalDocumentation | None = None, ge: float | None = None, gt: float | None = None, header: str | None = None, le: float | None = None, lt: float | None = None, max_items: int | None = None, max_length: int | None = None, min_items: int | None = None, min_length: int | None = None, multiple_of: float | None = None, pattern: str | None = None, query: str | None = None, required: bool | None = None, title: str | None = None, schema_extra: dict[str, Any] | None = None, schema_component_key: str | None = None, include_in_schema: bool = True) Any#

Create an extended parameter kwarg definition.

Parameters:
  • annotationEmpty by default.

  • const – A boolean flag dictating whether this parameter is a constant. If True, the value passed to the parameter must equal its default value. This also causes the OpenAPI const field to be populated with the default value.

  • content_encoding – The content encoding of the value. Applicable on to string values. See OpenAPI 3.1 for details.

  • cookie – The cookie parameter key - required for cookie parameters.

  • default – A default value. If const is true, this value is required.

  • description – String value used in the description section of the OpenAPI schema for the given parameter.

  • examples – A list of Example models.

  • external_docs – A url pointing at external documentation for the given parameter.

  • ge – Constrict value to be greater or equal to a given float or int. Equivalent to minimum in the OpenAPI specification.

  • gt – Constrict value to be greater than a given float or int. Equivalent to exclusiveMinimum in the OpenAPI specification.

  • header – The header parameter key - required for header parameters.

  • le – Constrict value to be less or equal to a given float or int. Equivalent to maximum in the OpenAPI specification.

  • lt – Constrict value to be less than a given float or int. Equivalent to exclusiveMaximum in the OpenAPI specification.

  • max_items – Constrict a set or a list to have a maximum number of items. Equivalent to maxItems in the OpenAPI specification.

  • max_length – Constrict a string or bytes value to have a maximum length. Equivalent to maxLength in the OpenAPI specification.

  • min_items – Constrict a set or a list to have a minimum number of items. ֿ Equivalent to minItems in the OpenAPI specification.

  • min_length – Constrict a string or bytes value to have a minimum length. Equivalent to minLength in the OpenAPI specification.

  • multiple_of – Constrict value to a multiple of a given float or int. Equivalent to multipleOf in the OpenAPI specification.

  • pattern – A string representing a regex against which the given string will be matched. Equivalent to pattern in the OpenAPI specification.

  • query – The query parameter key for this parameter.

  • required – A boolean flag dictating whether this parameter is required. If set to False, None values will be allowed. Defaults to True.

  • title – String value used in the title section of the OpenAPI schema for the given parameter.

  • schema_extra

    Extensions to the generated schema. If set, will overwrite the matching fields in the generated schema.

    Added in version 2.8.0.

  • schema_component_key – Use this as the key for the reference when creating a component for this type .. versionadded:: 2.12.0

  • include_in_schema – A boolean flag dictating whether this parameter should be included in the schema.

class litestar.params.ParameterKwarg#

Bases: KwargDefinition

Data container representing a parameter.

param_type: ClassVar[ParamType] = 'query'#

Type of the parameter

name: str | None = None#

Name of the parameter. If ‘None’, and used in a function annotation, the name will be inferred from the annotated parameter’s name.

annotation: Any = 0#

The field value - Empty by default.

header: str | None = None#

The header name - required for header parameters.

__init__(examples: list[Example] | None = None, external_docs: ExternalDocumentation | None = None, content_encoding: str | None = None, default: Any = _EmptyEnum.EMPTY, title: str | None = None, description: str | None = None, const: bool | None = None, gt: float | None = None, ge: float | None = None, lt: float | None = None, le: float | None = None, multiple_of: float | None = None, min_items: int | None = None, max_items: int | None = None, min_length: int | None = None, max_length: int | None = None, pattern: str | None = None, lower_case: bool | None = None, upper_case: bool | None = None, format: str | None = None, enum: Sequence[Any] | None = None, read_only: bool | None = None, schema_extra: dict[str, Any] | None = None, schema_component_key: str | None = None, include_in_schema: bool = True, name: str | None = None, annotation: Any = _EmptyEnum.EMPTY, header: str | None = None, cookie: str | None = None, query: str | None = None, required: bool | None = None) None#
cookie: str | None = None#

The cookie name - required for cookie parameters.

query: str | None = None#

The query parameter name - required for query parameters

required: bool | None = None#

A boolean flag dictating whether this parameter is required.

If set to False, None values will be allowed. Defaults to True.

__hash__() int#

Hash the dataclass in a safe way.

Returns:

A hash

class litestar.params.PathParameter#

Bases: ParameterKwarg

Describes a path parameter.

In the OpenAPI, this maps to a parameter in: path.

param_type: ClassVar[ParamType] = 'path'#

Type of the parameter

class litestar.params.QueryParameter#

Bases: ParameterKwarg

Describes a query parameter.

In the OpenAPI, this maps to a parameter in: query.

param_type: ClassVar[ParamType] = 'query'#

Type of the parameter