Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 50 additions & 9 deletions chapters/compatibility.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,66 @@ expected that code changes are necessary.
== {SHOULD} prefer compatible extensions

API designers should apply the following rules to evolve RESTful APIs for
services in a backward-compatible way:
services in a backward-compatible way.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
services in a backward-compatible way.
services in a compatible way.


In general:

* 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
customer-number to customer-id, as both are different unique customer keys)
customer-number to customer-id, both being unique, but different customer keys)

* Consider <<251>> in case a URL has to change.
Copy link
Member Author

@ePaul ePaul Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pointed wrongly to rule 250 before. (251 was originally added as 250 in #762 to a feature branch, but then #759 adding 250 was merged first to main before #781 renamed it and merged it into main.)

I also have a separate PR #852 to fix just this (already merged).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The compatibility of schema changes depends on whether the input and/or output objects are defined.

For schemas used in input only:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For schemas used in input only:
For schemas only used for *input objects*:


* Add only optional, never mandatory fields (and don't make optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Add only optional, never mandatory fields (and don't make optional
* Add optional fields, but never mandatory fields.
* Make mandatory fields optional, but not vice-versa.

fields mandatory).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fields mandatory).

* Don't remove fields.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Don't remove fields.
* Don't remove fields(*).

* While removing fields by itself doesn't break compatibility (if the
server would still accept it, possibly ignoring it, if sent by the client),
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.
Comment on lines +57 to +61
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* While removing fields by itself doesn't break compatibility (if the
server would still accept it, possibly ignoring it, if sent by the client),
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.

* Input fields may have (complex) constraints being validated via server-side
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Input fields may have (complex) constraints being validated via server-side
* Relax constraints: 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 when used as input parameters, only if the server
is ready to accept and handle old range values too. The range can be reduced
when used as output parameters.
* `enum` ranges cannot be extended when used for output parameters — clients may
not be prepared to handle it. However, enum ranges can be extended when used
for input parameters.
* `enum` ranges can be reduced when used as input, only if the server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `enum` ranges can be reduced when used as input, only if the server
* `enum` ranges can be reduced, only if the server

is ready to accept and handle old range values too.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is ready to accept and handle old range values too.
continues to accept and handle old range values.

* `enum` ranges can be extended when used for input.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `enum` ranges can be extended when used for input.
* `enum` ranges can be extended.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(*) Hint: Removing a field can be considered as a compatible change that does not break clients, in case the service still accepts and possibly ignores it if sent by the client. However, removed fields allow later adding a same-named field with different type or semantic (which is harder to catch). We therefore define field removal as non-compatible.

For schemas used in output only:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For schemas used in output only:
For schemas only used for output objects:


* New mandatory fields can be added, or existing optional ones be made mandatory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* New mandatory fields can be added, or existing optional ones be made mandatory.
* Add (mandatory or optional) fields.
* Make optional fields mandatory, but not vice-versa.

* Don't remove a mandatory field, or make it optional (clients might depend
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Don't remove a mandatory field, or make it optional (clients might depend
* Don't remove fields (*).

on it being filled).
* Don't remove optional fields either.
* While removing optional fields by itself doesn't break compatibility,
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.
Comment on lines +73 to +77
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
on it being filled).
* Don't remove optional fields either.
* While removing optional fields by itself doesn't break compatibility,
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `enum` ranges can be reduced when used as output.
* `enum` ranges can be reduced.

* `enum` ranges **cannot** be extended when used for output — clients may
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `enum` ranges **cannot** be extended when used for output — clients may
* `enum` ranges *cannot* be extended — clients may

not be prepared to handle it.
* 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(*) 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.

For schemas used in both input and output (which is common and recommended in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

many cases), both of these rule sets combine, i.e. you can only do changes which
are allowed in both input and output.

* 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.
Comment on lines +89 to 99
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

(and consumed by the owning service), this turns around.

[#109]
== {SHOULD} design APIs conservatively
Expand Down