Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for marshmallow.fields.Number.as_string #805

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

rockTA
Copy link

@rockTA rockTA commented Oct 19, 2022

Some applications serialize decimal numbers as strings, as binary representation of floats can't be precise. However, when the OpenAPI documentation is created, this is currently not being taken into account if the Decimal type is used with the as_string option. With this change the documentation accurately represents what is being returned.

@rockTA rockTA force-pushed the allow-using-marshmallow-number-as-string branch from ba74d7b to 904b343 Compare December 21, 2022 11:14
@rockTA
Copy link
Author

rockTA commented Dec 21, 2022

Push :)

Copy link
Member

@lafrech lafrech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing and sorry about the delay.

I think it would be nicer if we added a number2properties method overriding the output of field2type_and_format.

@matejsp
Copy link

matejsp commented Apr 25, 2023

This PR is also missing also adding format as decimal when using number as_string.

      amount:
          description: Some amount
          example: '90.00'
          readOnly: true
          type: string
          format: decimal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants