Comments (10)
My bad! Have opened a PR here #870
from apispec.
Thanks for reporting. Would you like to work on this (change + test)?
from apispec.
Yeah I've made the change and written a couple of tests for it, should I open a PR against dev?
from apispec.
Yes, please !
from apispec.
Cool, could I get access to create branch intzero/fix-decimal-range please?
from apispec.
The procedure is to push the branch to your GH fork, then open the PR.
from apispec.
Sorry for not spotting this any sooner, but I think the way to go is to set as_string=True
in Decimal
field, rather than adding field-specific code in a generic function.
See
- marshmallow-code/flask-smorest#517
- https://marshmallow.readthedocs.io/en/stable/marshmallow.fields.html#marshmallow.fields.Decimal
from apispec.
Yeah I saw your reply to the PR. I really don't think that asking people to change their business logic by changing the serializer to use a different variable type is a solution imho! Secondly, it isn't a solution anyway as you will end up with:
type: number
minimum: '0'
maximum: '1000000'
This range is processed by OpenAPI as a string and thus doesn't correctly display the range for this field since it is a number. The other problem you're going to have is when outputting yaml with Decimals. Seeing as pyyaml (the library that your to_yaml() function uses and seems to be the only viable yaml library for python) doesn't support them (which is why this issue is similar to the one you linked with the json library). There are a number of issues like this yaml/pyyaml#255 which have been open for years with no reply or merge so it doesn't look like it'll get fixed anytime soon either. Sometimes to fix a problem you need to make pragmatic concessions.
No problem - it's starting to look as though the solution is me writing a work-around in my doc build tools to specifically deal with Decimals. I can close my PR.
from apispec.
from apispec.
Now I'm wondering. If your API works, then I guess you're not using
standard json serializer.
The reason is that I didn't know that Flask JSON encoder had been improved to serialize decimals as well, so no need for a custom decimal serializer anymore.
My other points still stand. Users should use as_string
with Decimal
fields.
Closing for now. Feel free to comment for further discussion.
from apispec.
Related Issues (20)
- Issue with nested self-referencing schemas HOT 2
- Marshmallow plugin doesn't document the format of fields.DateTime() correctly HOT 3
- marshmallow plugin does not support `marshmallow.fields.Tuple` HOT 1
- What is the correct way to use add_attribute_function in the Marshmallow plugin? HOT 2
- additionalProperties=false is not set when using default Marshmallow schema options HOT 2
- callbacks in operation are not resolved to refs HOT 5
- wrong default value for 'name' in schema2parameters HOT 3
- parameters not being resolved for OAS3 'content' type parameters HOT 2
- Incorrect handling of marshmallow nested schema with allow_none=True in OpenAPI 3.1 HOT 4
- Incorrect handling of Union types HOT 2
- Deprecated flag is not configured correctly on query parameter objects
- sdist is missing `tox.ini` HOT 1
- Interest in taking Schema description from Schema.__doc__ docstring
- Document form data and images
- Enum by_value creates OpenAPI property without type HOT 11
- Deprecate __version__ attribute
- Add requestBody component HOT 14
- How to get Schema added to components/parameters? HOT 5
- Thanks for the report! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apispec.