Bug Report Checklist
Description
When there are any properties whos the names start with $ the generated Dto commandlets contain invalid code. $type is the default name of C# polymorphicly serialized classes/dtos.
{
"properties": {
"$type": {
"type": "string",
"enum": ["Dog", "Cat", "Fish"]
}
}
}
Invalid PS commandlet
$PSO = [PSCustomObject]@{
"$type" = ${Type}
"id" = ${Id}
"name" = ${Name}
"category" = ${Category}
"photoUrls" = ${PhotoUrls}
"tags" = ${Tags}
"status" = ${Status}
}
Since in pwsh "$type" wants to expand the type variable instead of setting $type as the name of the prop
The generated code should probably look like this:
$PSO = [PSCustomObject]@{
'$type' = ${Type}
'id' = ${Id}
'name' = ${Name}
'category' = ${Category}
'photoUrls' = ${PhotoUrls}
'tags' = ${Tags}
'status' = ${Status}
}
openapi-generator version
7.22.0-SNAPSHOT
Reproduction Repo
https://github.com/DesselBane/repro-pwsh-gen-dollar-bug
OpenAPI declaration file content or url
https://github.com/DesselBane/repro-pwsh-gen-dollar-bug/blob/master/openapi.json#L806
Generation Details
https://github.com/DesselBane/repro-pwsh-gen-dollar-bug/blob/master/generate.ps1
Steps to reproduce
- clone repo
- run
generate.ps1
- run
run.ps1
- run
test.ps1 <- this is where the error happens
Suggest a fix
- replace contents of
generated/src/PSOpenAPITools/Model/Pet.ps1 with Pet-Fixed.ps1
- run
run.ps1
- run
test.ps1
Bug Report Checklist
Description
When there are any properties whos the names start with
$the generated Dto commandlets contain invalid code.$typeis the default name of C# polymorphicly serialized classes/dtos.{ "properties": { "$type": { "type": "string", "enum": ["Dog", "Cat", "Fish"] } } }Invalid PS commandlet
Since in pwsh
"$type"wants to expand thetypevariable instead of setting$typeas the name of the propThe generated code should probably look like this:
openapi-generator version
7.22.0-SNAPSHOT
Reproduction Repo
https://github.com/DesselBane/repro-pwsh-gen-dollar-bug
OpenAPI declaration file content or url
https://github.com/DesselBane/repro-pwsh-gen-dollar-bug/blob/master/openapi.json#L806
Generation Details
https://github.com/DesselBane/repro-pwsh-gen-dollar-bug/blob/master/generate.ps1
Steps to reproduce
generate.ps1run.ps1test.ps1<- this is where the error happensSuggest a fix
generated/src/PSOpenAPITools/Model/Pet.ps1withPet-Fixed.ps1run.ps1test.ps1