Skip to content

feat(integrations): add Django REST Framework TypeIDField - #95

Open
Bortlesboat wants to merge 2 commits into
akhundMurad:mainfrom
Bortlesboat:feat-drf-field
Open

Bortlesboat wants to merge 2 commits into
akhundMurad:mainfrom
Bortlesboat:feat-drf-field

Conversation

@Bortlesboat

Copy link
Copy Markdown

Adds a DRF serializer field that validates TypeID strings through the core, optionally enforces a prefix, serializes TypeIDs as strings, and renders UUID primary keys as prefixed TypeIDs. Includes tests and a docs page next to the Pydantic one. OpenAPI-specific schema output isn't covered yet. pytest tests and make lint pass.

Refs #41

Serializer field that validates TypeID strings through the core,
optionally enforces a prefix, serializes TypeIDs as strings and renders
UUID primary keys as prefixed TypeIDs.

Refs akhundMurad#41
Comment thread typeid/integrations/drf/fields.py Outdated
import uuid

import uuid_utils
from rest_framework import serializers # type: ignore[import-untyped]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe, it worth to add some check and fail with proper message if DRF is not installed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in eb1cb33. Importing typeid.integrations.drf without DRF now raises an ImportError that says to pip install djangorestframework, and there is a test for it that patches rest_framework out of sys.modules.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants