Skip to content

Commit

Permalink
Merge branch 'zalando:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
skZeppelin committed Apr 8, 2024
2 parents 57d3d26 + d650980 commit fc6f5af
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
22 changes: 22 additions & 0 deletions chapters/best-practices.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,25 @@ later than the given date:
=== Conclusion
We suggest to either use the _{ETag} in result entities_ or _{Last-Modified}
/ {If-Unmodified-Since}_ approach.


[[handling-compatible-extensions]]
== Handling compatible API extensions

[[client-handling-compatible-extensions]]
=== In the clients

Client must not eliminate unknown optional fields from the
fetched resource payload, and to serialize them later when submitting the
complete resource payload back to the API server via {PUT} (<<108>>).

When using Java with Jackson serialization, for example, that can be achieved
by including a field in the Java class representing the API resource, like the
following one:

[source,java]
----
@JsonAnyGetter
@JsonAnySetter
private Map<String, JsonNode> additionalProperties = new HashMap<>();
----
1 change: 1 addition & 0 deletions chapters/compatibility.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Service clients should apply the robustness principle:
** Follow the redirect when the server returns HTTP status code {301} (Moved
Permanently).

The <<handling-compatible-extensions>> section describes a best practice to implement the requirements in Java.

[#111]
== {MUST} treat OpenAPI specification as open for extension by default
Expand Down
3 changes: 3 additions & 0 deletions chapters/http-requests.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ suggest to choose one and only one of the following patterns per endpoint

1. Use {PUT} with complete objects to update a resource as long as feasible
(i.e. do not use {PATCH} at all).
*Note:* this choice by the API server imposes additional requirements on
the client (<<108>>) which can be implemented e.g. in Java following the
practice <<handling-compatible-extensions>>.
2. Use {PATCH} with {RFC-7396}[JSON Merge Patch] standard, a
specialized media type `application/merge-patch+json` for partial
resource representation to update parts of resource objects.
Expand Down
2 changes: 1 addition & 1 deletion chapters/introduction.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Zalando’s software architecture centers around decoupled microservices
that provide functionality via RESTful APIs with a JSON payload. Small
engineering teams own, deploy and operate these microservices in their
AWS (team) accounts. Our APIs most purely express what our systems do,
AWS (team) accounts. Our APIs express most purely what our systems do,
and are therefore highly valuable business assets. Designing
high-quality, long-lasting APIs has become even more critical for us
since we started developing our new open platform strategy, which
Expand Down
4 changes: 4 additions & 0 deletions models/request-headers-1.0.0.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This document is DEPRECATED and only maintained for backward compatibility.
# Separation of request vs. response header definition is partially redundant and not needed.
# Instead, please use the HEADER DEFINITIONS provided in headers-<version>.yaml

# Standard Headers

If-Match:
Expand Down
4 changes: 4 additions & 0 deletions models/response-headers-1.0.0.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This document is DEPRECATED and only maintained for backward compatibility.
# Separation of request vs. response header definition is partially redundant and not needed.
# Instead, please use the HEADER DEFINITIONS provided in headers-<version>.yaml

# Standard Headers

Cache-Control:
Expand Down

0 comments on commit fc6f5af

Please sign in to comment.