From 67377b7c795d74cc0d794d4ae0fc82f17852123e Mon Sep 17 00:00:00 2001 From: Michael Dowling Date: Tue, 15 Sep 2020 12:16:57 -0700 Subject: [PATCH] Emit DANGER event for DELETE with a payload Lots of clients don't support DELETE with a payload, and the spec calls it out as having no defined semantics. The newly added event can be suppressed if necessary, but this action functions as a way of essentially "signing-off" on the risks associated with using a DELETE with a payload. --- .../HttpMethodSemanticsValidator.java | 2 +- .../http-method-semantics-validator.errors | 1 + .../http-method-semantics-validator.json | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/HttpMethodSemanticsValidator.java b/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/HttpMethodSemanticsValidator.java index 84caa95b540..5e45a1d3df2 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/HttpMethodSemanticsValidator.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/HttpMethodSemanticsValidator.java @@ -57,7 +57,7 @@ public final class HttpMethodSemanticsValidator extends AbstractValidator { "OPTIONS", new HttpMethodSemantics(true, false, false), "TRACE", new HttpMethodSemantics(true, false, false), "POST", new HttpMethodSemantics(false, null, true), - "DELETE", new HttpMethodSemantics(false, true, true), + "DELETE", new HttpMethodSemantics(false, true, false), "PUT", new HttpMethodSemantics(false, true, true), "PATCH", new HttpMethodSemantics(false, false, true)); diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-method-semantics-validator.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-method-semantics-validator.errors index d165cd88176..ae7a4da324a 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-method-semantics-validator.errors +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-method-semantics-validator.errors @@ -1,5 +1,6 @@ [DANGER] ns.foo#K: This operation uses the `GET` method in the `http` trait, but has the following members bound to the payload: `payload` | HttpMethodSemantics [DANGER] ns.foo#L: This operation uses the `GET` method in the `http` trait, but has the following members bound to the document: `payload` | HttpMethodSemantics +[DANGER] ns.foo#M: This operation uses the `DELETE` method in the `http` trait, but has the following members bound to the document: `payload` | HttpMethodSemantics [WARNING] ns.foo#G: This operation uses the `POST` method in the `http` trait, but is marked with the readonly trait | HttpMethodSemantics [WARNING] ns.foo#H: This operation uses the `DELETE` method in the `http` trait, but is not marked with the idempotent trait | HttpMethodSemantics [WARNING] ns.foo#I: This operation uses the `GET` method in the `http` trait, but is not marked with the readonly trait | HttpMethodSemantics diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-method-semantics-validator.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-method-semantics-validator.json index b26c0b4f9a9..14d5fff9226 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-method-semantics-validator.json +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/http-method-semantics-validator.json @@ -151,6 +151,27 @@ } } } + }, + "ns.foo#M": { + "type": "operation", + "input": { + "target": "ns.foo#MInput" + }, + "traits": { + "smithy.api#http": { + "method": "DELETE", + "uri": "/M" + }, + "smithy.api#idempotent": {} + } + }, + "ns.foo#MInput": { + "type": "structure", + "members": { + "payload": { + "target": "smithy.api#String" + } + } } } }