Skip to content

Commit

Permalink
🗑️ Deprecate more things that don't belong in zgw-consumers anymore
Browse files Browse the repository at this point in the history
* Deprecated OAS tooling
* Deprecated the DRF integration
  • Loading branch information
sergei-maertens committed Mar 29, 2024
1 parent 1500c90 commit d43eb4f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
Changes
=======

0.33.0 (2024-03-29)
-------------------

Deprecation release. We've deprecated more public API, but made sure to provide/offer
alternatives. This allows you to upgrade to newer versions of zgw-consumers already
while buying yourself enough time to update your project code.

We published some of the deprecated utilities in a separate package: ``zgw-consumers-oas``.

* Deprecated the OAS test utilities in ``zgw_consumers.test``:

- ``read_schema``: Use ``zgw_consumers_oas.read_schema`` if you need to.
- ``generate_oas_component``: Use ``zgw_consumers_oas.generate_oas_component`` if
you need to. However, we recommend using `VCR_`_ instead of manually
building API mocks, or leverage factory_boy_ to generate mock data.
- ``mock_service_oas_get``: there is no alternative because zgw-consumers no longer
fetches configured API schemas.

* Deprecated ``zgw_consumers.drf.serializers.APIModelSerializer``. Instead, use
`djangorestframework-dataclasses`_.

.. _VCR: https://vcrpy.readthedocs.io/en/latest/
.. _factory_boy: https://factoryboy.readthedocs.io/en/stable/
.. _djangorestframework-dataclasses: https://pypi.org/project/djangorestframework-dataclasses/

0.32.0 (2024-03-26)
-------------------

Expand Down
7 changes: 7 additions & 0 deletions zgw_consumers/drf/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@
from uuid import UUID

from rest_framework import fields, serializers
from typing_extensions import deprecated

from .utils import extract_model_field_type, get_field_kwargs


@deprecated(
"The APIModelSerializer is deprecated and will be removed in 1.0. "
"The package `djangorestframework-dataclasses` seems to be a drop-in replacement.",
category=DeprecationWarning,
stacklevel=2,
)
class APIModelSerializer(serializers.Serializer):
serializer_field_mapping = {
str: fields.CharField,
Expand Down
8 changes: 8 additions & 0 deletions zgw_consumers/test/component_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import yaml
from faker import Faker
from typing_extensions import deprecated

from .schema_mock import read_schema

Expand All @@ -20,6 +21,13 @@ def load_schema(service: str):
return yaml.safe_load(read_schema(service))


@deprecated(
"OAS (test) tooling is deprecated and scheduled for removal in 1.0. We recommend "
"writing your own factories, or alternatively `pip install zgw-consumers-oas` "
"for a drop-in replacement.",
category=DeprecationWarning,
stacklevel=2,
)
def generate_oas_component(
service: str,
component: str,
Expand Down
7 changes: 7 additions & 0 deletions zgw_consumers/test/schema_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
_cache = {}


@deprecated(
"OAS (test) tooling is deprecated and scheduled for removal in 1.0. We recommend "
"writing your own factories, or alternatively `pip install zgw-consumers-oas` "
"for a drop-in replacement.",
category=DeprecationWarning,
stacklevel=2,
)
def read_schema(service: str, extension=".yaml"):
schema_dirs = get_setting("ZGW_CONSUMERS_TEST_SCHEMA_DIRS")

Expand Down

0 comments on commit d43eb4f

Please sign in to comment.