-
Notifications
You must be signed in to change notification settings - Fork 222
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
[Python] Support for untyped Json #4385
Comments
Hi @andrueastman, I would like to work on this issue, could you please let me know starting point so that I can start my investigation, thanks |
Thanks for reaching out @rohitkrsoni To start with you'd need to create the types that have a
The next thing would be to update the serialization library to support serializing/deserializing these types in the Once these two are done we just need to remove this line in the python refiner so that the types show up in generation. (task 4)
We can then add tests and validate that the sdk generated for the endpoint Let us know if you need any other clarifications. |
Thanks for the above explanation @andrueastman, I think I have got an idea about what I need to do. But I am looking in why we need to do. As far as I have understood we are trying to handle the untyped JSON node. More specifically, those parameter which are not defined in the schema but they are in the response when API is hit. So these nodes should be handled and parsed during the runtime. I can see in the generated class that we do have |
Hi @andrueastman, could you please provide your insights here, thanks |
The existence of the However, in the event an Api response is not described (response schema is undefined), this mean that the API would not return an object (property names and their values), so the return type can't be an object if it's a primitive or a collection as a dictionary couldn't be used to represent the values and we would need to generate a return type value. The scenario also applies to scenarios where a property could return multi-dimensional arrays which would complicate the serializer/deserialization logic as well as the number of dimensions would need to be known beforehand for the serializer serialize effectively. See example at #4549 Let me know if this helps clarifies this abit more. |
Thanks for the additional info @andrueastman, I have created a basic I have also created a I am trying to log the response to the console with the below code:
I am getting the value of And while debugging I can see the correct value of in non Am I doing something wrong here? Meanwhile I will continue to look into it. Once it is figured out and I get the value of the Untyped Node for Edit 1: When I use And the method Edit 2: Okay, so I am getting the value of name with this piece of extra code:
My understanding is, we need to serialize the But, while reserializing it, we are also passing the type which we want to deserialize to But how will the project implementing the generated Client will know the type of the |
You can checkout a sample at here Essentially, since you don't know the type, you'lll need to call the |
Here, is the PR of added untyped nodes. microsoft/kiota-python#286, please review, thanks |
Serialization Support for UntypedNodes: microsoft/kiota-python#356 |
I appreciate that you are doing towards supporting |
Unfortunately, not as far as I know. We could imagine creating this class as a placeholder to unblock people while waiting on the implementation work to be completed if that helps. |
Thanks @baywet . Currently, the generated source does not even have an import statement for UntypedNode, so I feel that the existence of a UntypedNode class, even as a placeholder, is easier to deal with this issue. |
we could add the imports once we have a placeholder as well. |
Thanks @baywet . I'm newbie at Python, so I'll take a look into this at first. |
Similar to #4095 we need to add support for untyped content in request/response payloads.
In summary, we need to
UntypedNode
base type in the abstractions library (see Create types for untyped nodes kiota-dotnet#177)UntypedNode
to represent object, array and primitive types in the abstractions (see Create types for untyped nodes kiota-dotnet#177)getObjectValue
method in the json serialization library to handle scenarios of untyped content (see Support untyped nodes kiota-serialization-json-dotnet#198)RemoveUntypedNodePropertyValues
in the refiner so that untyped properties are not stripped out.The text was updated successfully, but these errors were encountered: