Azure / Azure/autorest.powershell
Support for nullable properties for POST, PATCH, and PUT operations
- Dominant language
- C#
- Stars
- 123
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
Given an OpenAPI document containing a schema with nullable properties (available at https://gist.github.com/peombwa/1f426dc4c1be72c448b3f6008bb8905e):
``` yml
... # Shortened
'/users/{user-id}':
patch:
tags:
- users.user
summary: Update user
operationId: users.user_UpdateUser
parameters:
- name: user-id
in: path
description: 'key: id of user'
required: true
schema:
type: string
x-ms-docs-key-type: user
requestBody:
description: New property values
content:
application/json:
schema:
$ref: '#/components/schemas/microsoft.graph.user'
required: true
responses:
'204':
description: Success
default:
$ref: '#/components/responses/error'
x-ms-docs-operation-type: operation
components:
schemas:
microsoft.graph.user:
allOf:
- $ref: '#/components/schemas/microsoft.graph.directoryObject'
- title: user
type: object
properties:
mobilePhone:
type: string
description: 'The primary cellular telephone number for the user. Read-only for users synced from on-premises directory. Supports $filter (eq, ne, not, ge, le, in, startsWith, and eq on null values).'
nullable: true
additionalProperties:
type: object
... # Shortened
```
## Expected behavior
AutoREST.PowerShell should generate commands that support nullification of nullable properties:
``` powershell
Update-MgUser -UserId $UserId -MobilePhone $null
```
With the request body serialized as:
``` json
{
"mobilePhone": null
}
```
## Current behavior
``` powershell
Update-MgUser -UserId $UserId -MobilePhone $null
```
Serializes the request body as:
``` json
{
"mobilePhone": ""
}
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.