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

Set the format of marshmallow.fields.Float fields to float #862

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

ddorian
Copy link

@ddorian ddorian commented Oct 1, 2023

See float format for number data types https://swagger.io/docs/specification/data-models/data-types/

@lafrech
Copy link
Member

lafrech commented Oct 1, 2023

Shouldn't it be double?

https://swagger.io/docs/specification/data-models/data-types/

Or system-dependent?

https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex

Floating point numbers are usually implemented using double in C; information about the precision and internal representation of floating point numbers for the machine on which your program is running is available in sys.float_info.

We can't rely (solely) on sys.float.info as the doc may be generated on another machine than the one running the API.

@ddorian
Copy link
Author

ddorian commented Oct 2, 2023

Shouldn't it be double?

Yes.

We can't rely (solely) on sys.float.info as the doc may be generated on another machine than the one running the API.

That is the problem with the dev IMO. What do you propose?

@lafrech
Copy link
Member

lafrech commented Dec 21, 2023

Since we can't tell, I'd say leave things as is and let the user override if needed.

We may want to document this, though.

@ddorian
Copy link
Author

ddorian commented Dec 22, 2023

Maybe we can add a validator to make the "type" (example on Function/Method fields) or format (Float,Number,etc) required ?

@lafrech
Copy link
Member

lafrech commented Dec 22, 2023

I'm sorry, I don't understand what you mean.

@ddorian
Copy link
Author

ddorian commented Dec 22, 2023

I'm sorry, I don't understand what you mean.

I've added a validator that checks that all Float fields should have "type" defined, just to be "consistent" on the openapi output.
I've done that for "FunctionField" & "MethodField", but made "type" required there.

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.

2 participants