Open mbursill opened 1 month ago
Hi @mbursill Thanks for using kiota and for reaching out. QQ: are you enabling the backing store when you generate your client?
Tested with both backing store and without. The generated model is:
export interface UpdateWidgetRequest extends BackedModel, Parsable {
/**
* Stores model information.
*/
backingStoreEnabled?: boolean;
/**
* The inspectionDetails property
*/
inspectionDetails?: InspectionDetails;
/**
* The mass property
*/
mass?: number;
/**
* The name property
*/
name?: string;
/**
* The size property
*/
size?: number;
}
The fields are all optional, meaning they're union with undefined, but assigning null is not possible.
Thanks for the additional information. Is your goal of passing null to have null in the JSON payload to reset a field of an object for example? The serialization writer already contains a method to write a null value but I don't think it was thought about end to end: the prototype of the methods would need to be updated, and we'd need all the implementations to test for the null value.
Is your goal of passing null to have null in the JSON payload to reset a field of an object for example?
Yes, that's exactly what we're wanting it for. Undefined doesn't work for us in this case. Our API uses undefined to mean a change to the field was not made, and not to alter the value. To clear/reset the value we need null.
Thanks for the additional context. Yes, this is probably a limitation of the design and code generation today we should work to fix. The first step is most likely to update all the interfaces (ParseNode, SerializationWriter, BackingStore,...) so parameters or return types also allow null as a value. Is this something you'd be interested in submitting a pull request for?
any updates on this?
Hey @baywet, I want to contribute.
How I can generate kiota.exe
build after adding changes to packages?
@rners01 you can run it straight in process if you want with a single command
dotnet run --project ./src/kiota/kiota.csproj -- arguments you usually pass to kiota
or you can tweak the .vscode/launch.json if you are using vs code.
Make sure you have dotnet sdk 8 installed first
Thanks for the time and help!
@baywet but I don't see no ./src/kiota/kiota.csproj
in kiota-typescript
repo
sorry, I meant in the main repo
but then I don't understand, I have changes in kiota-typescript
and seems like kiota
is totally different project
how can I generate the .exe with kiota-typescript
changes?
the kiota typescript repository only contains the typescript libraries (abstractions, serialization, http, authentication,...) the generation happens in the main kiota repository.
do you have any high-level instruction what changes should I apply to process null
along with generation of .exe?
let's start with the TypeScript changes if you don't mind? Can you put a pull request together to make the following changes please? We'll then proceed to the generation changes as you won't be able to test them until the libraries here are updated.
Our API depends on null's being allowed as part of the request:
This is different than sending undefined for inspectionDetails. Our API treats undefined on patch as no change, but null as a means to clear the value.
While the swagger file defines the type as nullable, the generated code only allows
InspectionDetails | undefined
We've tried to hack a value by doing:
inspectionDetails: <InspectionDetails>(<unknown>null)
This is awful and still doesn't work. This call to writeObjectValue strips it.