Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
johnthagen opened this issue Mar 23, 2022 · 2 comments
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@johnthagen
Copy link
Contributor

johnthagen commented Mar 23, 2022

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
@tfranzel
Copy link
Owner

well, that was a kind of obvious oversight, but iteration is our business, right? 😆

@tfranzel tfranzel added bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending labels Mar 25, 2022
@johnthagen
Copy link
Contributor Author

I can confirm that 0.22.1 fixes this issue. Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

2 participants