-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][PowerShell] Parameter of type array passed in pipeline: only first element is processed #19663
Comments
This implementation of
|
... only when the parameter is passed in the pipeline. If it is specified as a named parameter the process block should rather be
|
@wing328
However this is going to cause a major change to the mustache file. |
Bug Report Checklist
Description
The issue affects functions
New-PSUsersWithArrayInput
andNew-PSUsersWithListInput
in PSPetStore API.The parameter
$User
has typePsCustomObject[]
and has the attributeValueFromPipeline = $true
.The body of the function consists of a single
Process {}
block that ends with areturn
statement.In PowerShell the
Process {}
block is executed once for each input object that reaches the function, so the actual behaviour is the serialization the first element, the execution ofInvoke-PSApiClient
and a return to the caller.openapi-generator version
OpenAPI declaration file content or url
user.yml
Generation Details
Standard generation of PSPetStore client library
Steps to reproduce
Both
New-PSUsersWithArrayInput
andInvoke-PSApiClient
show a single object being processed (*):(*) The function
Out-DebugParameter
was modified by adding the parameter-Wrap
toFormat-Table
in order to show the full body.Related issues/PRs
Array context not maintained when converting a parameter to JSON #18427
Suggest a fix
The main product of the function produced by
api.mustache
is a JSON serialization of the input, and this requires the whole input object to be passed at once toConvertTo-JSON
. Actually, in PowerShell 5 the behavior ofConvertTo-JSON
is such that the output may not be correct when the input object is passed from the pipeline.IMHO there are two options:
ValueFromPipeline
attribute when the main parameter is an array type.Process {}
block to reconstruct the input array, and pass this variable toConvertTo-Json
in theEnd {}
block of the function. This option shall ensure that the serialization of the reconstructed collection is the same as the original one.The text was updated successfully, but these errors were encountered: