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

Change of 'default' not detected

Open michael-schnell opened this issue 2 years ago • 2 comments

Currently adding/changing/removing a 'default' is not detected.

V1

schema:
    type: integer

V2 (with 'default' added)

schema:
    type: integer
    default: -1

Same with changing/removing it.

michael-schnell avatar Mar 03 '23 10:03 michael-schnell

@michael-schnell Thanks for reporting this!

I think adding a default for a property is a compatible change and removing it is a breaking change.

What do you think?

joschi avatar Mar 04 '23 10:03 joschi

This is difficult. I guess this depends on where the default is located (request or response) and what kind of change it is.

The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided.

This means that the default only matters when nullable: true.

Response (Backward compatibility required)

  • Adding a default value: Old clients may interpret a missing field with their own "default" value and now receive a new default = BREAKING
  • Removing a default value: Old clients still interpret a missing value the same way as before = COMPATIBLE
  • Changing a default value: Old clients still use the old default, which is now wrong = BREAKING

Request (Forward compatibility required)

  • Adding a default value: Nothing was defined before about what happens on the server if the field is missing. Now it's more concrete = COMPATIBLE
  • Removing a default value: Old clients may not send a value and expect it to be the old default on the server = BREAKING
  • Changing a default value: Old clients expect the old default value to be stored when they don't send the field = BREAKING

michael-schnell avatar Mar 04 '23 14:03 michael-schnell