Skip to content

Cannot write null to a nullable value #1188

Closed
microsoft/kiota
#5106

Description

Our API depends on null's being allowed as part of the request:

const updateWidgetRequest: UpdateWidgetRequest = {
  name: 'Sproket',
  size: 5,
  inspectionDetails: null,
};

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    WIPbugSomething isn't workingtype:bugA broken experience

    Type

    No type

    Projects

    • Status

      Done ✔️

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions