openapi-generator 7.5 PowerShell client supports submission of multipart/form-data
via Invoke-RestMethod
. In particular, the -Form
parameter supports file contents. From the Invoke-RestMethod
documentation:
If the value is a System.IO.FileInfo object, then the binary file contents will be submitted. The name of the file will be submitted as the filename.
Unfortunately the value of the path is correct only when the input path is absolute. The issue is due to the fact that, when the path is relative, the full path is calculated using as directory the value returned by [System.IO.Directory]::GetCurrentDirectory()
, which is a constant rather than the value returned by Get-Location
.
openapi-generator-cli 7.5.0
OpenAPI declaration file content or urlThe issue was first noticed using a PowerShell client generated from Connectwise PSA API specs. The specs are too complex (over 4K endpoints) to be used for an example.
Generation Detailsopenapi-generator generate --input-spec SPECS/2024.1/All.json --generator-name powershell --output PSClient --additional-properties=packageName=CWPSA,packageVersion=2024.1,apiNamePrefix=PSA --skip-validate-spec
Steps to reproduceThe behaviour can be verified on a PowerShell console:
PS /Users/condorcorde/Git/cwpsa-client-frmw-ps> dir ./Build.sh
Directory: /Users/condorcorde/Git/cwpsa-client-frmw-ps
UnixMode User Group LastWriteTime Size Name
-------- ---------- ----- ------------- ---- ----
-rwxr-xr-x condorcorde staff 04.09.2023 17:11 1047 Build.sh
PS /Users/condorcorde/Git/cwpsa-client-frmw-ps> $f = [System.IO.FileInfo]::new('./Build.sh')
PS /Users/condorcorde/Git/cwpsa-client-frmw-ps> $f.FullName
/Users/condorcorde/Build.sh
PS /Users/condorcorde/Git/cwpsa-client-frmw-ps> [System.IO.Directory]::GetCurrentDirectory()
/Users/condorcorde
Related issues/PRs
None found
Suggest a fixA possibility - compatible with both PS5 and PS7 - would be to transform parameters of type [System.IO.FileInfo]
to make sure that the resulting path is absolute:
$File = $executionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($File)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4