OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.91k stars 6.58k forks source link

[BUG] Issue with zeroBasedEnums option in OpenAPI Generator #16894

Open ELHAROUI opened 1 year ago

ELHAROUI commented 1 year ago

Hello,

I am currently working with OpenAPI Generator to generate a C# SDK for my API. I'm facing an issue with the zeroBasedEnums option. According to the documentation, setting this option to true should make enums start with 0, but it doesn't seem to be working as expected.

Here's the relevant part of my configuration file:

{
    "zeroBasedEnums": true
}

Despite setting zeroBasedEnums to true, the generated enums still start with 1. I have searched through the documentation and forums, but I couldn't find a solution. Is there something I might be missing or is this a known issue with OpenAPI Generator?

devhl-labs commented 1 year ago

It should work. I recommend you leave it as the default value. That would make it start at zero only if the first entry is unknown. The benefit of this approach is that it reserves zero for unknown, meaning it can be added later without messing up any stored data.

devhl-labs commented 1 year ago

@ELHAROUI I tested this again and it looks like it works. I think you're just passing in the value incorrectly.