Skip to main content

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.8.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

drf_apischema-0.1.8-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file drf_apischema-0.1.8.tar.gz.

File metadata

  • Download URL: drf_apischema-0.1.8.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for drf_apischema-0.1.8.tar.gz
Algorithm Hash digest
SHA256 4e8727891b0759d3ca39eab6d4b0c2829a874adb6270cef2bbbbd4ca1975fbe5
MD5 f1fa8eb7d4c3fda153053c29aeba9bf4
BLAKE2b-256 4d75a7516882c7419bb8392cbda59eca97ce84483a8c69c77b75e5bb04110876

See more details on using hashes here.

File details

Details for the file drf_apischema-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for drf_apischema-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b8eeb80534ecc122c929c63e2238e7e1f8d3e8b1db42b2420eb9f35b583ab0d7
MD5 36d64b9d9e03eb7254bb827ab6a43505
BLAKE2b-256 f3c0af0f9be2f3c591e9c5fdf949df60711295f9f56a2653d612c1edc525de4b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page