Skip to content

get_schema returns "description" as "The type of the None singleton" #1418

@sparrowt

Description

@sparrowt

Describe the bug

Calling get_schema on a drf_spectacular.generators.SchemaGenerator sometimes returns a schema with a very odd description string of "The type of the None singleton."

{
  "openapi": "3.0.3",
  "info": {
    ...
  },
  "paths": {
    ...
    "/myapi/v1/thing/lookup/{lookup}/": {
      "get": {
        "operationId": "thing_lookup_retrieve",
        "description": "The type of the None singleton.",
        "parameters": [
          {
            ...

This first occurred when upgrading from Python 3.12 to 3.13 although I haven't yet 100% convinced myself that the python version is the cause (we had to upgrade several other unrelated-as-far-as-I-can-see packages to get 3.13 support) but certainly the drf-spectacular version remains unchanged at drf-spectacular==0.26.2.

To Reproduce

It's a private project however the rough shape of the view code in question is like this:

class LookupView(generics.RetrieveAPIView):
    permission_classes = [...]
    authentication_classes = [...]
    action = "lookup"

    lookup_field = "xyz__iexact"
    lookup_url_kwarg = "lookup"


class ThingLookupView(LookupView):
    queryset = Thing.objects.all()
    serializer_class = ThingSerializer

However I have stepped through in a debugger to get_description and observed that in this case action_or_method == None and thus action_doc ends up as "The type of the None singleton."

Expected behavior

The "description" should continue to be omitted, as it was before.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions