swagger-api / swagger-api/swagger-codegen
[PowerShell] Incorrect declaration of parameter type, when the parameter is of type Dictionary/Hashtable.
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When using codegen to output PowerShell code based on [X] OpenAPI specification parameters of datatype are not declared in the proper PowerShell syntax. See this attached picture as an example -->
Swagger-codegen
- v2.2.3 downloaded from https://oss.sonatype.org/content/repositories/releases/io/swagger/swagger-codegen-cli/2.2.3/
- I execute it on a Win7 SP1 computer with critical patches up until last month.
Swagger declaration file content or url
Gist containing the OctopusDeploy OpenAPI implementation json file:
Command line used for generation
java -jar swagger-codegen-cli-2.2.3.jar generate -i ./octopusDeploy.json -o outputfolderName -c config.json
config.json content
{
"packageName": "Danske.Spil.Octopus.Deploy.API"
}
Steps to reproduce
- Execute the cmdline written under "Swagger declaration file content or url" above.
- Open the folder containing the generated code in any IDE
- Open for example the file named: "New-AccountResource.ps1". It is located underneath
DRIVE:\PATH_TO_OUTPUT_FOLDER\src\IO.Swagger\Model\
Related issues/PRs
Haven't found one. Did a search both in the closed and the open issues.
Suggest a fix/enhancement
As the Dictionary and Hashtable types are almost similar it could be an option to declare a dictionary type as [Hashtable]. So for an PowerShell function parameter it would look like this:
function New-AccountResource {
[CmdletBinding()]
Param (
[System.Nullable[HashTable]]
${Links}
)
..............
Additional note
- Why is the API and Model parts of an OpenAPI implementing API being generated into a folder named "IO.Swagger"?
When the "Private" folder and .psm1 file are generated under a folder respecting the > packageName specified inside the config.json file? See this attached picture as an example:
- Also, why is the parameter type being declared as
[System.Nullable]?
Thank you and I'm looking forward to hear from you. Let me know if there is anything I can elaborate further upon. Have a great day/evening (where ever you are).
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
Run the listed swagger-codegen-cli command with the linked OpenAPI input and inspect src\IO.Swagger\Model\New-AccountResource.ps1. Compare the generated Dictionary/Hashtable parameter declaration with the requested PowerShell syntax, and check whether the [System.Nullable] and packageName folder behavior are part of the same generator output. Done means the generated parameter type is valid PowerShell for dictionary values and the related output behavior is clarified or corrected.
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