attrs

class litestar.plugins.attrs.AttrsSchemaPlugin[源代码]

基类:OpenAPISchemaPlugin

static is_plugin_supported_type(value: Any) bool[源代码]

Given a value of indeterminate type, determine if this value is supported by the plugin.

This is called by the default implementation of is_plugin_supported_field() for backwards compatibility. User's should prefer to override that method instead.

参数:

value -- An arbitrary value.

返回:

A bool indicating whether the value is supported by the plugin.

to_openapi_schema(field_definition: FieldDefinition, schema_creator: SchemaCreator) Schema[源代码]

Given a type annotation, transform it into an OpenAPI schema class.

参数:
  • field_definition -- FieldDefinition instance.

  • schema_creator -- An instance of the schema creator class

返回:

An OpenAPI instance.

litestar.plugins.attrs.is_attrs_class(annotation: Any) TypeGuard[type[AttrsInstance]][源代码]

Given a type annotation determine if the annotation is a class that includes an attrs attribute.

参数:

annotation -- A type.

返回:

A typeguard determining whether the type is an attrs class.