From 6c42260d74ab2fd92e9d1b0e2e32d11fc62d2a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Sat, 11 Apr 2026 11:49:38 +0200 Subject: [PATCH 1/2] Require `@required` trait on payloads --- .../src/main/resources/META-INF/smithy/jsonrpclib.smithy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/smithy/src/main/resources/META-INF/smithy/jsonrpclib.smithy b/modules/smithy/src/main/resources/META-INF/smithy/jsonrpclib.smithy index 6303ce1..1a0505b 100644 --- a/modules/smithy/src/main/resources/META-INF/smithy/jsonrpclib.smithy +++ b/modules/smithy/src/main/resources/META-INF/smithy/jsonrpclib.smithy @@ -36,11 +36,11 @@ string jsonRpcNotification /// Binds a single structure member to the payload of a jsonrpc message. /// Just like @httpPayload, but for jsonRpc. -@trait(selector: "structure > member", structurallyExclusive: "member") +@trait(selector: "structure > member[trait|required]", structurallyExclusive: "member") @traitValidators({ - "jsonRpcPayload.OnlyTopLevel": { - message: "jsonRpcPayload can only be used on the top level of an operation input/output/error.", - severity: "ERROR", + "jsonRpcPayload.OnlyTopLevel": { + message: "jsonRpcPayload can only be used on the top level of an operation input/output/error.", + severity: "ERROR", selector: "$allowedShapes(:root(operation -[input, output, error]-> structure > member)) :not(:in(${allowedShapes}))" } }) From c597b3f315d5c38fb112f3a1ac423328debd78c8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 12 Apr 2026 20:28:28 +0000 Subject: [PATCH 2/2] Add @required to members using @jsonRpcPayload in tests Agent-Logs-Url: https://github.com/neandertech/jsonrpclib/sessions/dad5d46a-60c1-4f9a-9ecb-5086d01823af Co-authored-by: kubukoz <894884+kubukoz@users.noreply.github.com> --- .../src/test/scala/jsonrpclib/JsonPayloadValidatorSpec.scala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/smithy-tests/src/test/scala/jsonrpclib/JsonPayloadValidatorSpec.scala b/modules/smithy-tests/src/test/scala/jsonrpclib/JsonPayloadValidatorSpec.scala index e72cb39..bf68b2a 100644 --- a/modules/smithy-tests/src/test/scala/jsonrpclib/JsonPayloadValidatorSpec.scala +++ b/modules/smithy-tests/src/test/scala/jsonrpclib/JsonPayloadValidatorSpec.scala @@ -31,17 +31,20 @@ object JsonPayloadValidatorSpec extends FunSuite { |} | |structure OpInput { + | @required | @jsonRpcPayload | data: String |} | |structure OpOutput { + | @required | @jsonRpcPayload | data: String |} | |@error("client") |structure OpError { + | @required | @jsonRpcPayload | data: String |} @@ -76,6 +79,7 @@ object JsonPayloadValidatorSpec extends FunSuite { |} | |structure NestedStructure { + | @required | @jsonRpcPayload | data: String |}