datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

Option to ignore enum constraints

Open adam-iris opened this issue 9 months ago • 0 comments
trafficstars

Is your feature request related to a problem? Please describe. I'm trying to create a client for an API whose json schema includes enums that may be expanded without warning. This appears to violate best practices (see https://opensource.zalando.com/restful-api-guidelines/#112) but I don't really have sway over the schema authors, and I think a robust client should be prepared for this (see https://opensource.zalando.com/restful-api-guidelines/#108).

Describe the solution you'd like A command line flag that causes enum constraints to be ignored; the generated code would simply use the defined type (eg. "string").

Describe alternatives you've considered I'm currently modifying the schema definition to replace "enum" with "x-extensible-enum" as described at https://opensource.zalando.com/restful-api-guidelines/#112 The code generator appears to ignore "x-extensible-enum" entirely, which produces the desired result, but this doesn't seem like a sustainable strategy moving forward.

Additional context

adam-iris avatar Feb 08 '25 01:02 adam-iris