-
Notifications
You must be signed in to change notification settings - Fork 210
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
Nested JSON/additional_data datetimes not round-tripped #5743
Comments
Thanks for raising this @thelazydogsback As the item is placed in the Any chance you are able to confirm the version of the python libraries you are using with your generated client? |
My microsoft-kiota libs were a bit stale -- but unfortunately updating to latest (1.6.2) didn't change the behavior. Does this mean I can write a subclass that implements |
Thank you for the additional information. To be specific, I don't believe the ask from Andrew was for you to add custom code to your application, but rather he was asking if you'd be willing to work on a pull request to fix the issue for everybody. I think the first step here would be to add a unit test similar to this one which would instead call "write_any_value" with a datetime value, and see whether we get the desired behaviour. This way we could determine whether the issue comes from serialization or deserialization. Let us know if you have any additional comments or questions. |
Yes I understand the request but (not trying to be rude at all) I'll see what I can do, but my first order of business is to get the required functionality working for our users. Outside of this bug (assuming it is one) I assume that overriding the behavior of dynamic data handling is useful because whatever default assumptions are made are likely not what some clients need in certain scenarios. |
UPDATE: @andrueastman (2) In order to fix this at serialization time, I'm figured I'd write a custom serializer to handle this. I used the factory pattern and the classes below: However, there seems to be a bug where the factory is used when the writer is first created, but then later in the code the factory is ignored when a temp writer is created: This means that by the time we get want to write the date from the parent [EDIT] So obviously |
Thank you for the additional information. So if I'm understand correctly, the only remaining issue at this point is that when parsing a date only for additional properties, it's being instantiated as a datetime instead of a date only? If so this section is most likely what's causing the issue here. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Windows executable
Client library/SDK language
Python
Describe the bug
I am trying to GET my entity, and without any changes to the object, PUT the object.
Expected behavior
I expect the object to be the same when serialized to the server for the PUT as when it was read with the GET
(either exactly, or at least semantically equivalent.)
How to reproduce
The entity contains an arbitrarily nested JSON object that should maintain its integrity when reserialized.
When the entity is GET on the Python side when deserialized it looks like this:
e.Contents.additional_data['installationDate'] = DateTime(2023, 3, 24, 0, 0, 0, tzinfo=TimeZone('UTC'))
In this case the JSON value had the string value "2023-03-24".
I expect this value to be serialized back out as either the original format "2023-03-24" by not converting to a date but keeping the original string, or by serializing as "2023-03-24T00:00:00+00:00". (The former is preferred.)
(This example is at the top-level, but also happens in deeper nestings.)
However, when the entity is PUT back, what gets serialized is the empty object - inspecting in the debugger in the C# server, the PUT controller method sees this entry in the dictionary - an empty object rather than the date string:
installationDate = ValueKind(Object, "{}")
How do I keep the original string format of the dates and round-trip them exactly?
And for reference, how to keep the DateTimes and serialize them back out as ISO format strings rather than the empty objects?
thanks
Open API description file
Unable to provide
Kiota Version
1.19.1
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
x64, vscode
Debug output
Click to expand log
```The text was updated successfully, but these errors were encountered: