Skip to content

Conversation

@bahkauv70
Copy link
Contributor

@bahkauv70 bahkauv70 commented Jan 16, 2025

Definitions of the following structure lead to broken code in the generator:

"MyEnum": {
        "enum": [
          "foo",
          "bar",
          baz"
        ],
        "format": "enum",
        "type": "string"
      }

The additional format specifier is copied verbatim as the base datatype for the enum, leading to broken code if the type is not a builtin type.
The fix for this is to remove the support for the format specifier in the template. This is is a valid approach, because:

  • openapi only supports enum for strings, i.e. the basetype always have to be a string
  • the format specifier is open-valued (see here), i.e. the application is generator specific
  • the base type for the enum can still be changed using the type attribute (even if no enum values can be defined for types other than string!)
  • the change has no effect on the current generated API

@bahkauv70 bahkauv70 marked this pull request as ready for review January 16, 2025 13:28
@bahkauv70 bahkauv70 merged commit 37a2da6 into main Jan 20, 2025
22 checks passed
@bahkauv70 bahkauv70 deleted the fix/stackitsdk-73-Go-generator-creates-broken-code-for-enums branch January 20, 2025 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants