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 |} 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}))" } })