From 4d710c75d171ec4c43e531b75f043379e18b370f Mon Sep 17 00:00:00 2001 From: rhysrevans3 Date: Mon, 19 Aug 2024 09:25:00 +0100 Subject: [PATCH 1/6] Adding support for RF6902 for path requests. --- README.md | 3 +- openapi.yaml | 89 ++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 82 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4face4e..3f07fdd 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,8 @@ All cases: - Must return 404 if no Item exists for this resource URI. - If the `id` or `collection` fields are different from those in the URI, status code 400 shall be returned. -PATCH is compliant with [RFC 7386](https://tools.ietf.org/html/rfc7386). +PATCH is compliant with [RFC 7386](https://tools.ietf.org/html/rfc7386) through `application/json-merge+json` and +[RFC 6902](https://tools.ietf.org/html/rfc6902) through `application/json-patch+json`. ### DELETE diff --git a/openapi.yaml b/openapi.yaml index 7073329..363a5a5 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -22,7 +22,7 @@ paths: - $ref: "https://api.stacspec.org/v1.0.0/ogcapi-features/openapi.yaml#/components/parameters/collectionId" post: summary: add a new STAC Item or Items in an ItemCollection to a collection - description: create a new STAC Item r Items in an ItemCollection in a specific collection + description: create a new STAC Item or Items in an ItemCollection in a specific collection operationId: postFeature tags: - Transaction @@ -137,8 +137,10 @@ paths: patch: summary: update an existing feature by Id with a partial item definition description: >- - Use this method to update an existing feature. Requires a GeoJSON - fragment (containing the fields to be updated) be submitted. + Use this method to update an existing feature. merge-patch adheres to RF7396 and requires a GeoJSON + fragment (containing the fields to be updated) be submitted. Null values in the merge patch are + given special meaning to indicate the removal of existing values in the target. json-patch adheres + to RF6902 and requires a sequence of opperations to perform on the target feature. operationId: patchFeature tags: - Transaction @@ -146,12 +148,16 @@ paths: - $ref: "#/components/parameters/IfMatchOptional" requestBody: content: - application/json: + application/merge-patch+json: + schema: + $ref: "#/components/schemas/mergePatchItem" + application/json-patch+json: schema: - $ref: "#/components/schemas/patchItem" + $ref: "#/components/schemas/patchRequest" + responses: "200": - description: The item was replaced + description: The item was updated headers: ETag: schema: @@ -162,7 +168,7 @@ paths: schema: $ref: "https://api.stacspec.org/v1.0.0/ogcapi-features/openapi.yaml#/components/schemas/item" "202": - description: The item was accepted for asynchronous action + description: The request was accepted for asynchronous action "204": description: Status of the update request. headers: @@ -228,9 +234,74 @@ components: schema: type: string schemas: - patchItem: + patchRequest: + description: >- + An array that containing the sequence of opperations to apply to the target item. + type: array + items: + oneOf: + - $ref: '#/components/schemas/patchRequestAddReplaceTest' + - $ref: '#/components/schemas/patchRequestRemove' + - $ref: '#/components/schemas/patchRequestMoveCopy' + patchRequestAddReplaceTest: + type: object + additionalProperties: false + required: + - value + - op + - path + properties: + path: + description: A JSON Pointer path. + type: string + value: + description: The value to add, replace or test. + op: + description: The operation to perform. + type: string + enum: + - add + - replace + - test + patchRequestRemove: + type: object + additionalProperties: false + required: + - op + - path + properties: + path: + description: A JSON Pointer path. + type: string + op: + description: The operation to perform. + type: string + enum: + - remove + patchRequestMoveCopy: + type: object + additionalProperties: false + required: + - from + - op + - path + properties: + path: + description: A JSON Pointer path. + type: string + op: + description: The operation to perform. + type: string + enum: + - move + - copy + from: + description: A JSON Pointer path. + type: string + mergePatchItem: description: >- - An object that contains at least a subset of the fields for a STAC Item. + An object that contains at least a subset of the fields for a STAC Item. Null values in the merge + patch are given special meaning to indicate the removal of existing values in the target. type: object properties: stac_version: From ea04c500e54a2e2c171075423c52cd7c786c63fe Mon Sep 17 00:00:00 2001 From: rhysrevans3 Date: Mon, 19 Aug 2024 09:33:55 +0100 Subject: [PATCH 2/6] Adding to CHANGELOG. --- CHANGELOG.md | 10 ++++++++++ README.md | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4981ee..fabcd97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Support for [RFC 6902](https://tools.ietf.org/html/rfc6902) [#14](https://github.com/stac-api-extensions/transaction/pull/14) + +### Changed + +- Updated of [RFC 7386](https://tools.ietf.org/html/rfc7386) to [RFC 7396](https://tools.ietf.org/html/rfc7396) [#14](https://github.com/stac-api-extensions/transaction/pull/14) + ## [v1.0.0-rc.3] - 2023-09-28 - Remove assertion that this will align with OAF Part 4. diff --git a/README.md b/README.md index 3f07fdd..80a17f2 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ All cases: - Must return 404 if no Item exists for this resource URI. - If the `id` or `collection` fields are different from those in the URI, status code 400 shall be returned. -PATCH is compliant with [RFC 7386](https://tools.ietf.org/html/rfc7386) through `application/json-merge+json` and +PATCH is compliant with [RFC 7396](https://tools.ietf.org/html/rfc7396) through `application/json-merge+json` and [RFC 6902](https://tools.ietf.org/html/rfc6902) through `application/json-patch+json`. ### DELETE From c7872308dc2ca7b2bc620c9c752af0df95f7a8b1 Mon Sep 17 00:00:00 2001 From: rhysrevans3 Date: Mon, 19 Aug 2024 10:45:21 +0100 Subject: [PATCH 3/6] Fixing readme typo. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 80a17f2..0e1d43a 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ All cases: - Must return 404 if no Item exists for this resource URI. - If the `id` or `collection` fields are different from those in the URI, status code 400 shall be returned. -PATCH is compliant with [RFC 7396](https://tools.ietf.org/html/rfc7396) through `application/json-merge+json` and +PATCH is compliant with [RFC 7396](https://tools.ietf.org/html/rfc7396) through `application/merge-patch+json` and [RFC 6902](https://tools.ietf.org/html/rfc6902) through `application/json-patch+json`. ### DELETE From d89bcf9e90707723423cf572b0f05bd2d482bc26 Mon Sep 17 00:00:00 2001 From: rhysrevans3 Date: Mon, 19 Aug 2024 11:24:35 +0100 Subject: [PATCH 4/6] Adding original patch content type to stop breaking changes. --- openapi.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 363a5a5..3c85a6e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -148,13 +148,15 @@ paths: - $ref: "#/components/parameters/IfMatchOptional" requestBody: content: + application/json: + schema: + $ref: "#/components/schemas/mergePatchItem" application/merge-patch+json: schema: $ref: "#/components/schemas/mergePatchItem" application/json-patch+json: schema: $ref: "#/components/schemas/patchRequest" - responses: "200": description: The item was updated From d4d47b401eb338829e700c1e4c232f5e50b9727c Mon Sep 17 00:00:00 2001 From: rhysrevans3 Date: Tue, 15 Oct 2024 08:42:05 +0100 Subject: [PATCH 5/6] Updating PATCH description to better distinguish the two methods. --- openapi.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 3c85a6e..8e96084 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -137,10 +137,12 @@ paths: patch: summary: update an existing feature by Id with a partial item definition description: >- - Use this method to update an existing feature. merge-patch adheres to RF7396 and requires a GeoJSON - fragment (containing the fields to be updated) be submitted. Null values in the merge patch are - given special meaning to indicate the removal of existing values in the target. json-patch adheres - to RF6902 and requires a sequence of opperations to perform on the target feature. + Use this method to update an existing feature. The default method, merge-patch adheres to RF7396 + and requires a GeoJSON fragment (containing the fields to be updated) be submitted. Null values in + the merge patch are given special meaning to indicate the removal of existing values in the + target. Optionally json-patch, which adheres to RF6902 and requires a sequence of opperations to + perform on the target feature, can be included. The two methods can be distinguished via the + Accept/Content-Type header. operationId: patchFeature tags: - Transaction From c440faf0039992488eea26ba582a34cfcc78b6b8 Mon Sep 17 00:00:00 2001 From: rhysrevans3 Date: Tue, 15 Oct 2024 10:52:21 +0100 Subject: [PATCH 6/6] Update PATCH section of README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e1d43a..3e7ba12 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,9 @@ All cases: - Must return 404 if no Item exists for this resource URI. - If the `id` or `collection` fields are different from those in the URI, status code 400 shall be returned. -PATCH is compliant with [RFC 7396](https://tools.ietf.org/html/rfc7396) through `application/merge-patch+json` and -[RFC 6902](https://tools.ietf.org/html/rfc6902) through `application/json-patch+json`. +The default standard for PATCH is [RFC 7396](https://tools.ietf.org/html/rfc7396). +Optionally, in addition to RFC 7396, [RFC 6902](https://tools.ietf.org/html/rfc6902) can be supported with the two methods +being distinguished via the Accept/Content-Type header. ### DELETE