OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.23k stars 6.43k forks source link

[REQ] Add Decimal Support for Python #19198

Closed m-standfuss closed 4 weeks ago

m-standfuss commented 1 month ago

Is your feature request related to a problem? Please describe.

We have a financial api so it deals alot with money, which means we deal with Decimal class in python alot. We tried to use the open api generator for those decimal values and it barfed on us. In order to fix we forked and added this logic in

https://github.com/OpenAPITools/openapi-generator/commit/5ade1775efae9dd866260046c0abe8f6a3fe3f4b.patch

Describe the solution you'd like

I would like decimal backed fields in the API spec to be handled correctly.

Describe alternatives you've considered

This was earlier this year, and I wish I would have logged this sooner when I still had all of my notes, but we tried a ton of different options to try and get the generator to recognize our open api spec as decimals but none worked as documented. We ended up forking and writing those couple of lines in the patch code above on python's api_client.mustache file and it worked perfect.

Additional context

If we are using the generator incorrectly and it does support decimal for python out of the box please let me know but I found all the documentation around it confusing and contradicting.

If the proposed patch file code looks good I can submit it as a PR instead.

wing328 commented 1 month ago

please open a PR to start with and we will review accordingly

m-standfuss commented 1 month ago

Thanks for the look @wing328 here is the PR https://github.com/OpenAPITools/openapi-generator/pull/19203

i will work on getting the build step setup so i can run it and include as well later today.

Run the following to [build the project](https://github.com/OpenAPITools/openapi-generator#14---build-projects) and update samples: