[BUG][powershell] Reusable enum schemas generates invalid .ps1 files
Created by: dordadush
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[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: string
enum:
- direct
- hosted
##### Generation Details
using the powershell generator without any flags or template configurations.