Closed hognevevle closed 2 months ago
Thanks for raising this @hognevevle
The function takes 3 parameters ideally including a serializeFunction
.
Any chance you can share a full sample that replicates the scenario to help understand the issue better?
Hi @andrueastman
Yes, there is indeed a serializeFunction
being passed as well.
export function serializeApiCartItemItemAddRequest(writer: SerializationWriter, apiCartItemItemAddRequest: Partial<ApiCartItemItemAddRequest> | undefined = {}) : void {
writer.writeObjectValue<ApiCartItem>("item", apiCartItemItemAddRequest.item, serializeApiCartItem);
}
[...]
export function serializeApiCartItem(writer: SerializationWriter, apiCartItem: Partial<ApiCartItem> | undefined = {}) : void {
writer.writeObjectValue<ApiCartItem>("foo", apiCartItem.foo, serializeApiFooCartItem); // apiCartItem.foo is undefined
writer.writeObjectValue<ApiCartItem>("bar", apiCartItem.bar, serializeApiBarCartItem); // apiCartItem.bar is an object
}
serializeApi{Foo,Bar}CartItem
contains a writer.writeStringValue(...)
for each of its properties.
Not sure if this helps -- I'm unable to provide a full code reproduction right now, but let me know if needed and I'll try to prepare that later this week.
Hi @hognevevle, could you provide a simplified version of the API that demonstrates the issue? Feel free to rename fields and remove any unnecessary sections. This will help us reproduce the problem more easily and work towards finding a solution. Thank you!
Seems to be covered by https://github.com/microsoft/kiota-typescript/issues/1190 for which a fix has been merged. Closing for now.
I have a generated model that looks like this:
When consuming the relevant API, and passing the model as
{ bar: {...} }
(item
being the key that gets passed towriter.writeObjectValue
), the resulting JSON is:{"item":{,"bar":{...}},
Notice the invalid
,
being added to the beginning of theitem
object. The data being passed in towriter.writeObjectValue(...)
is valid, but afterwards, the data coming back incontentAsStr
(below) now contains the invalid,
.1.0.0-preview.50