openapi-diff
openapi-diff copied to clipboard
ENUM changes
Discussed in https://github.com/OpenAPITools/openapi-diff/discussions/292
Originally posted by Roman-Bober November 25, 2021 Hi, I wonder why enum changes gives "brocken backward compatability" Shouldn't be if enum is added at the end of enum list it should be backward compatible?
Thank you, Roman
I too am seeing the above issue whe appending an item to a string enum.
@jackbilestech Changes to enums are not breaking in every programming language or in Java it is breaking and causes runtime errors. That is why Zalando works with x-extensible-enum
https://opensource.zalando.com/restful-api-guidelines/#112.
There are numerous solutions on the market, but no official ones in the OpenAPI standard.
See also: https://github.com/OpenAPITools/openapi-diff/discussions/292#discussioncomment-2265299
While it's up to the specific implementation of clients how to act on the change, adding a previously invalid value to an existing enum is a breaking change in my opinion.
We might be able to reach a decision here, but can we add a parameter to the CLI to allow us to treat ENUM as a breaking change or not. Something similar to https://openapi-generator.tech/docs/generators/java enumUnknownDefaultCase
parameter does
To echo what @doshidhaval said, an enum addition can be considered a compatible change if a default
case exists (say: UNKNOWN
) but otherwise is breaking.
This gets thornier when considering evolution over time however (imagine changing a default enum value to something that previously didn't exist).