openapi-diff icon indicating copy to clipboard operation
openapi-diff copied to clipboard

ENUM changes

Open jackbilestech opened this issue 2 years ago • 4 comments

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 avatar Dec 17 '21 16:12 jackbilestech

@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.

cTAbdIsi avatar Jan 07 '22 10:01 cTAbdIsi

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.

joschi avatar Feb 28 '22 12:02 joschi

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

doshidhaval avatar Apr 29 '22 20:04 doshidhaval

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).

mcwhitak avatar May 16 '22 15:05 mcwhitak