Django Rest Framework

Package: zgw_consumers.drf

Support downstream APIs using django-rest-framework.

This package includes support for API’s using API models. In this way, the API acts as a gateway API, consuming services defined by zgw-consumers, and re-formatting/serializing the data back into the downstream API responses. A typical set-up would be a Single-Page-App having its own dedicated gateway API, which fetches data from other services so that the SPA only has one backend to consider.

Serializers

Support “ModelSerializer” for dataclass based “models”.

The APIModelSerializer is able to introspect the class typehints to generate the appropriate serializer fields.

Currently the support is experimental.

class zgw_consumers.drf.serializers.APIModelSerializer(*args, **kwargs)[source]

Serializer fields

class zgw_consumers.drf.fields.ServiceUrlApiField(*args, **kwargs)[source]

Serializer field for database ServiceUrlField field

class zgw_consumers.drf.fields.ServiceValidator[source]

Validate that url belongs to the known Service