Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change of 'default' not detected #484

Open
michael-schnell opened this issue Mar 3, 2023 · 2 comments
Open

Change of 'default' not detected #484

michael-schnell opened this issue Mar 3, 2023 · 2 comments

Comments

@michael-schnell
Copy link

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.

@joschi
Copy link
Contributor

joschi commented Mar 4, 2023

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

@michael-schnell
Copy link
Author

michael-schnell commented Mar 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants