OpenAPITools / OpenAPITools/openapi-generator
[BUG] [PS] : PsData specified in config file leads to invalid module manifest file
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
When we specify the psdata in config file to generate the PowerShell SDK it add separate properties called PSData which causes the failure of import module
openapi-generator version
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
#config file configuration
psData : "LicenseUri = 'https://www.apache.org/licenses/LICENSE-2.0.txt'"
PowerShell SDK generated code in Build.ps1
PrivateData = @{
PSData = @{
LicenseUri = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
After running the Build.ps1 generated module file has followings
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
} # End of PSData hashtable
# PSData
PSData = 'System.Collections.Hashtable'
} # End of PrivateData hashtable
After running the Build.ps1 module manifest file generated with invalid value , On import of the module
PS C:\> Import-Module -Name .\Petstore.psd1
Import-Module : The module manifest 'C:\Petstore.psd1' could not be processed because it is not a valid PowerShell module manifest file. Remove the elements that are not permitted: At C:\Petstore.psd1:144 char:5
+ PSData = 'System.Collections.Hashtable'
+ ~~~~~~
Duplicate keys 'PSData' are not allowed in hash literals.
At line:1 char:1
+ Import-Module .\Intersight.psd1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (C:\Petstore.psd1:String) [Import-Module], MissingMemberException
+ FullyQualifiedErrorId : Modules_InvalidManifest,Microsoft.PowerShell.Commands.ImportModuleCommand
Related issues/PRs
Suggest a fix
Directly expose the psData property in config file and provide these property as parameter instead of adding via PrivataData parameter
New-ModuleManifest -LicenseUri "xxxx" -Tags @("xx","xx") -ReleaseNotes "xxxxx"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated Build.ps1 and the resulting PowerShell module manifest (.psd1), using the issue's psData configuration to reproduce the duplicate PSData entry. Run Import-Module against the generated manifest and compare it with the shown output. Done means the manifest imports successfully without duplicate PSData keys while preserving the configured metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100