Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 1.7 KB

serialization.rst

File metadata and controls

50 lines (37 loc) · 1.7 KB

Serialization

transmute-core provides a framework and default implementation to allow serializing objects to and from common data representation for an API. This is by chaining two parts:

  1. object serialization to / from basic Python data types.
  2. data types serialization to / from standard data notations (e.g. json or yaml)

out of the box, object serialization is supported for:

  • bool
  • float
  • int
  • str
  • decimal.Decimal
  • datetime.datetime
  • lists, denoted by the form [<type] (deprecated)
  • schematics models.
  • schematics types
    • if a type class is passed, it will initialize the class to an instance.
  • support for attrs classes, that are using type annotations.
  • types denoted using the typing module (installed as a separate package for python versions older than 3.5)

Serialization Behavior

The intention is to ensure that serialization and deserialization of types matches that of openapi, to ensure that the UI prffovided is usable.

This forces behaviors such as multiple arguments being consumed as a comma-separated argument per query parameter, rather than just as multiple query parameter with the same name.

Customization

TransmuteContext

Both of these components are customizable, either through passing a new TransmuteContext object, or modifying the default instance.

To learn more about customizing these serializers, please see the API reference for TransmuteContext, ObjectSerializer, and ContentTypeSerializer.