Closed pjmagee closed 4 months ago
temporary fix:
"value": lambda n : setattr(self, 'value', float(n._json_node),
Hi @pjmagee
Thanks for using kiota and for reporting this.
Assuming we apply the fix you've suggested, when it's an int, should we also do float(int_source)
so consumers can properly leverage type testing?
Also I'll be transferring this to the serialization library where the implementation bug is.
Hi @pjmagee Thanks for using kiota and for reporting this. Assuming we apply the fix you've suggested, when it's an int, should we also do
float(int_source)
so consumers can properly leverage type testing? Also I'll be transferring this to the serialization library where the implementation bug is.
I'm not sure to be honest! I am trying to get some 'dog fooding' of our APIs happening while also using Code generation to speed things up, One of our analysts found this issue and I helped debug and fix it so they could continue to ingest data from the API with Kiota (and not go an alternative route). However your point about the type testing, I'm really not sure!
I don't think we need type testing personally, when we develop an API and it's a JSON API, we would do tests on ther JSON implementation, I dont want to test via Kiota, i want Kiota purely for code generation and to trust it will handle situations properly.
ok, thanks for the additional input. I think it'd make sense that a method with float in the name returns a float. Are you willing to submit a pull request to address the issue?
ok, thanks for the additional input. I think it'd make sense that a method with float in the name returns a float. Are you willing to submit a pull request to address the issue?
If it's as simple as what I had suggested, I think I can raise the pull request for this. Unsure on how best to test everything from a local environment. I'm not a Python expert or Python user really.
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Nuget tool
Client library/SDK language
Python
Describe the bug
When a response from an API, says in the OpenAPI Spec it can be a non whole number (float, number), the Python is only returning a numeric value, when the value itself is a literal float, if the number seems to be whole number, it is returning None.
Expected behavior
Whole numbers should also be taken into consideration, this seems like quite a big problem! Let's take prices as an example, £3.20 as a float is valid, but £3 is also valid. However, in situations where whole numbers (integers) are returned, the float is not parsed. I would expect float(3) to be returned?
Something like this maybe?
Type "help", "copyright", "credits" or "license" for more information.
An OpenAPI Specification can say that an API contains numbers other than whole numbers, but here Python needs to ensure the number is maintained and not lost into a 'None'
How to reproduce
I think it's happening all the time, based on the functionality implemented for get_float_value
Open API description file
Partial OpenAPI description:
Kiota Version
1.16.0
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
No response
Debug output
Click to expand log
```Other information
No response