You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I'm defining a reusable enum schema in my OpenAPI 3 spec file and reuse this schema in other schema fields to avoid writing the same enum values multiple times.
This results in generated .ps1 files with an empty expression which PowerShell does not accept:
function ConvertFrom-JsonToApplicationType {
Param(
[AllowEmptyString()]
[string]$Json
)
Process {
'Converting JSON to PSCustomObject: PSOpenAPITools => ApplicationType' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$JsonParameters = ConvertFrom-Json -InputObject $Json
# check if Json contains properties not defined in ApplicationType
$AllProperties = ()
foreach ($name in $JsonParameters.PsObject.Properties.Name) {
if (!($AllProperties.Contains($name))) {
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
}
}
$PSO = [PSCustomObject]@{
}
return $PSO
}
}
The line of $AllProperties = () generates an error in the Build.ps1 process:
Get-ChildItem : At C:\XXXXX\Model\ApplicationType.ps1:70 char:27
+ $AllProperties = ()
+ ~
An expression was expected after '('.
openapi-generator version
version 5.0.0
OpenAPI declaration file content or url
components:
schemas:
ApplicationType:
type: stringenum:
- direct
- hosted##### Generation Detailsusing the powershell generator without any flags or template configurations.
The text was updated successfully, but these errors were encountered:
I'm not a PowerShell expert, but the fix seems to be using @() instead of () when generating the variable. This shorthand works both when values are declared and when none are declared.
Bug Report Checklist
Description
I'm defining a reusable enum schema in my OpenAPI 3 spec file and reuse this schema in other schema fields to avoid writing the same enum values multiple times.
This results in generated .ps1 files with an empty expression which PowerShell does not accept:
The line of
$AllProperties = ()
generates an error in the Build.ps1 process:openapi-generator version
version 5.0.0
OpenAPI declaration file content or url
The text was updated successfully, but these errors were encountered: