Skip to content

[BUG] [PowerShell] enum label must not start with a digit #21769

@benwa

Description

@benwa

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

If you have an enum that start with a digit, (for example 100, 200, 3test), the resulting PS1 will error out.

openapi-generator version

7.14.0

OpenAPI declaration file content or url

https://redfish.dmtf.org/schemas/v1/SerialInterface.v1_3_0.yaml#/components/schemas/SerialInterface_v1_3_0_SerialInterface

Generation Details

PowerShell 7.5, Redfish OpenAPI spec.

Steps to reproduce
open-api-generator -i https://redfish.dmtf.org/schemas/v1/SerialInterface.v1_3_0.yaml#/components/schemas/SerialInterface_v1_3_0_SerialInterface -g powershell

Which will result in a ps1 with an enum.

enum SerialInterface_v1_3_0_BitRate {
     1200
     2400
     4800
     9600
     19200
     38400
     57600
     115200
     230400
}

PowerShell does not like this format.

Related issues/PRs
Suggest a fix

Begin the enum with an underscore (which is how the C# generator works). I'm not sure of the logic to then use the correct value for the resulting API call, however.

enum SerialInterface_v1_3_0_BitRate {
     _1200 = 1200
     _2400 = 2400
     _4800 =4800
     _9600 = 9600
     _19200 = 19200
     _38400 = 38400
     _57600 = 57600
     _115200 = 115200
     _230400 = 230400
}

Alternatively, perhaps an array is better than an actual enum.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions