Skip to content

OpenApiParameter with Python float type is incorrectly labeled as float (32-bit) OpenAPI format rather than double (64-bit) #687

@johnthagen

Description

@johnthagen

Describe the bug
OpenApiParameter with the native Python float type is formatted as a 32-bit float rather than 64-bit double.

Related to #674

To Reproduce

Use drf-spectacular 0.22.0.

input_param = OpenApiParameter(
    name="input",
    description="Description",
    type=float,
    default=1.0,
)


class MyViewSet(RetrieveModelMixin, GenericViewSet):
    @extend_schema(parameters=[input_param])
    def retrieve(self, request: Request, *args: Any, **kwargs: str) -> Response:
        ...

The resulting schema:

        schema:
          type: number
          format: float
          default: 1.0

Expected behavior

Expected schema

        schema:
          type: number
          format: double
          default: 1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfix confirmation pendingissue has been fixed and confirmation from issue reporter is pending

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions