-
Couldn't load subscription status.
- Fork 432
Clearly separate compatibility rules for input and output schemas. #851
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
base: main
Are you sure you want to change the base?
Conversation
| * Never change the semantic of fields (e.g. changing the semantic from | ||
| customer-number to customer-id, as both are different unique customer keys) | ||
| customer-number to customer-id, as both are different unique customer keys) | ||
| * Consider <<251>> in case a URL has to change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
7154a27 to
099c0c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for providing more clarity on compatible changes -- it is needed.
I provided some change proposals to further enhance clarity and avoid redundancies.
|
|
||
| API designers should apply the following rules to evolve RESTful APIs for | ||
| services in a backward-compatible way: | ||
| services in a backward-compatible way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| services in a backward-compatible way. | |
| services in a compatible way. |
|
|
||
| * Add only optional, never mandatory fields. | ||
| * Never change the semantic of fields (e.g. changing the semantic from | ||
| customer-number to customer-id, as both are different unique customer keys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| customer-number to customer-id, as both are different unique customer keys) | |
| customer-number to customer-id, both being unique, but different customer keys) |
| * Never change the semantic of fields (e.g. changing the semantic from | ||
| customer-number to customer-id, as both are different unique customer keys) | ||
| customer-number to customer-id, as both are different unique customer keys) | ||
| * Consider <<251>> in case a URL has to change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| * Never change the semantic of fields (e.g. changing the semantic from | ||
| customer-number to customer-id, as both are different unique customer keys) | ||
| * Consider <<251>> in case a URL has to change. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The compatibility of schema changes depends on whether the input and/or output objects are defined. | |
| customer-number to customer-id, as both are different unique customer keys) | ||
| * Consider <<251>> in case a URL has to change. | ||
|
|
||
| For schemas used in input only: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| For schemas used in input only: | |
| For schemas only used for *input objects*: |
| it then would allow later to add a same-named field with different type | ||
| or semantic (which is harder to catch). Therefore, this is also considered a non-compatible change. | ||
| * `enum` ranges can be reduced when used as output. | ||
| * `enum` ranges **cannot** be extended when used for output — clients may |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * `enum` ranges **cannot** be extended when used for output — clients may | |
| * `enum` ranges *cannot* be extended — clients may |
| * You <<112>> that are used for output parameters and likely to | ||
| be extended with growing functionality. The API definition should be updated | ||
| first before returning new values. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| (*) Hint: Removing an optional field can be considered as a compatible change that does not break clients. However, removed fields allow later adding a same-named field with different type or semantic (which is harder to catch). We therefore define optional field removal as non-compatible. | |
| be extended with growing functionality. The API definition should be updated | ||
| first before returning new values. | ||
|
|
||
| For schemas used in both input and output (which is common and recommended in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| For schemas used in both input and output (which is common and recommended in | |
| For schemas used in both input and output (which is typical in |
| * Add only optional, never mandatory fields. | ||
| * Don't remove any fields. | ||
| * Don't make mandatory fields optional or make optional fields mandatory. | ||
| * Input fields may have (complex) constraints being validated via server-side | ||
| business logic. Never change the validation logic to be more restrictive and | ||
| make sure that all constraints are clearly defined in description. | ||
| * `enum` ranges can be reduced only if the server is ready to still accept and | ||
| handle old values. They **cannot** be extended. | ||
| * You <<112>> that are used for output parameters and likely to | ||
| be extended with growing functionality. The API definition should be updated | ||
| first before returning new values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Add only optional, never mandatory fields. | |
| * Don't remove any fields. | |
| * Don't make mandatory fields optional or make optional fields mandatory. | |
| * Input fields may have (complex) constraints being validated via server-side | |
| business logic. Never change the validation logic to be more restrictive and | |
| make sure that all constraints are clearly defined in description. | |
| * `enum` ranges can be reduced only if the server is ready to still accept and | |
| handle old values. They **cannot** be extended. | |
| * You <<112>> that are used for output parameters and likely to | |
| be extended with growing functionality. The API definition should be updated | |
| first before returning new values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is is a consequence of the sentence before, and redundant -- should be omitted.
| * Consider <<251>> in case a URL has to change. | ||
|
|
||
| Input/Output here is from the perspective of a service implementing and | ||
| owning the API. For the rare case of APIs implemented by other services |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| owning the API. For the rare case of APIs implemented by other services | |
| owning the API. For the rare case of call-back APIs implemented by other services |
Triggered by a discussion in an internal chat (internal link), this makes it clearer which of the compatibility rules apply for input and output schemas, respectively.