Repository: smithy-lang/smithy
Pull request #2595 (2025-04-17 20:09:59)

Add nascent document type support for rpcv2Cbor
As the compatibility of document types across protocols that use different wire serialization formats (JSON, CBOR) is built, it must be possible to specify them together. Using documents with rpcv2Cbor is still a DANGER level event, as it won't work in most cases.

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.



Patch:
diff --git a/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy b/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy
index 68c672b7b..0421081f6 100644
--- a/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy
+++ b/smithy-protocol-traits/src/main/resources/META-INF/smithy/smithy.protocols.rpcv2.smithy
@@ -18,7 +18,8 @@ use smithy.api#httpError
 @traitValidators(
     "rpcv2Cbor.NoDocuments": {
          selector: "service ~> member :test(> document)"
-         message: "This protocol does not support document types"
+         message: "This protocol does not support document types in most possible scenarios."
+         severity: "DANGER"
     }
 )
 structure rpcv2Cbor {


Test patch:
diff --git a/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/nascent-document-support.errors b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/nascent-document-support.errors
new file mode 100644
index 000000000..8a43792d8
--- /dev/null
+++ b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/nascent-document-support.errors
@@ -0,0 +1,1 @@
+[DANGER] smithy.example#DocumentOperationInput$document: Found an incompatible shape when validating the constraints of the `smithy.protocols#rpcv2Cbor` trait attached to `smithy.example#DocumentService`: This protocol does not support document types in most possible scenarios. | rpcv2Cbor.NoDocuments
diff --git a/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.smithy b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/nascent-document-support.smithy
similarity index 100%
rename from smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.smithy
rename to smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/nascent-document-support.smithy
diff --git a/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.errors b/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.errors
deleted file mode 100644
index 1062699e1..000000000
--- a/smithy-protocol-traits/src/test/resources/software/amazon/smithy/protocol/traits/errorfiles/no-document-support.errors
+++ /dev/null
@@ -1,1 +0,0 @@
-[ERROR] smithy.example#DocumentOperationInput$document: Found an incompatible shape when validating the constraints of the `smithy.protocols#rpcv2Cbor` trait attached to `smithy.example#DocumentService`: This protocol does not support document types | rpcv2Cbor.NoDocuments