No project description provided
Project description
Usage
from django.urls import include, path
from rest_framework import serializers
from rest_framework.decorators import api_view
from rest_framework.routers import DefaultRouter
from rest_framework.viewsets import ViewSet
from drf_apischema import apischema
class AOut(serializers.ListSerializer):
child = serializers.IntegerField()
class BQuery(serializers.Serializer):
n = serializers.IntegerField(default=2)
class AViewSet(ViewSet):
@apischema(response=AOut)
def list(self, request):
return [1, 2, 3]
@api_view(["GET"])
@apischema(query=BQuery, transaction=False)
# def b_view(request, serializer: BQuery, data: dict):
def b_view(request, data: dict):
n: int = data["n"]
return n * n
router = DefaultRouter()
router.register("a", AViewSet, basename="a")
urlpatterns = [
path("", include(router.urls)),
path("b/", b_view),
]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
drf_apischema-0.1.4.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file drf_apischema-0.1.4.tar.gz
.
File metadata
- Download URL: drf_apischema-0.1.4.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64d2ccab9ca6e28c33bc5e3958dd7e2bb563514467c06e6b344ed613a145b1d8 |
|
MD5 | d6c2fad5f522c295dd9a91afbcc82b7e |
|
BLAKE2b-256 | 9d32f55bf99c5ae4fec52ce6aca81a068b2cd384799032979ca57ee88279fe08 |
File details
Details for the file drf_apischema-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: drf_apischema-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fa96d97352d7fa1deff335aa331733d5c149429f084e0233fb2df81796fc0c7 |
|
MD5 | 693613260da1162eae28a239a50d46e3 |
|
BLAKE2b-256 | f7571f3de9d1e763fd6cf1b5eec984619fef0e84fd6a6d96122485ac172619d9 |