[Default] update isAdditionalPropertiesTrue tag to cover more types (#16227)

* enhance additional properties support

* update samples

* update tests

* add more tests

* update samples

* fix samples
This commit is contained in:
William Cheng
2023-08-05 13:32:43 +08:00
committed by GitHub
parent c080660cc1
commit f6fb83878b
142 changed files with 2965 additions and 332 deletions

View File

@@ -89,12 +89,14 @@ function ConvertFrom-PSJsonToDrawing {
$PSBoundParameters | Out-DebugParameter | Write-Debug
$JsonParameters = ConvertFrom-Json -InputObject $Json
$PSDrawingAdditionalProperties = @{}
# check if Json contains properties not defined in PSDrawing
$AllProperties = ("mainShape", "shapeOrNull", "nullableShape", "shapes")
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
# store undefined properties in additionalProperties
if (!($AllProperties.Contains($name))) {
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
$PSDrawingAdditionalProperties[$name] = $JsonParameters.PSobject.Properties[$name].value
}
}
@@ -127,6 +129,7 @@ function ConvertFrom-PSJsonToDrawing {
"shapeOrNull" = ${ShapeOrNull}
"nullableShape" = ${NullableShape}
"shapes" = ${Shapes}
"AdditionalProperties" = $PSDrawingAdditionalProperties
}
return $PSO

View File

@@ -137,12 +137,14 @@ function ConvertFrom-PSJsonToNullableClass {
$PSBoundParameters | Out-DebugParameter | Write-Debug
$JsonParameters = ConvertFrom-Json -InputObject $Json
$PSNullableClassAdditionalProperties = @{}
# check if Json contains properties not defined in PSNullableClass
$AllProperties = ("integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable")
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
# store undefined properties in additionalProperties
if (!($AllProperties.Contains($name))) {
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
$PSNullableClassAdditionalProperties[$name] = $JsonParameters.PSobject.Properties[$name].value
}
}
@@ -231,6 +233,7 @@ function ConvertFrom-PSJsonToNullableClass {
"object_nullable_prop" = ${ObjectNullableProp}
"object_and_items_nullable_prop" = ${ObjectAndItemsNullableProp}
"object_items_nullable" = ${ObjectItemsNullable}
"AdditionalProperties" = $PSNullableClassAdditionalProperties
}
return $PSO