Skip to content

[PowerShell] Incorrect declaration of parameter type, when the parameter is of type Dictionary/Hashtable. #6645

@larssb

Description

@larssb
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 -->

swaggerdictionaryissue_171009

Swagger-codegen
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
  1. Execute the cmdline written under "Swagger declaration file content or url" above.
  2. Open the folder containing the generated code in any IDE
  3. 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:

swaggerdictionaryissue_folderstruct_171009

  • 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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions