From 96a684ba4a5d79efb02a8108a92c01faebca2e2a Mon Sep 17 00:00:00 2001 From: Michael Dowling Date: Sat, 11 Jan 2020 20:01:18 -0800 Subject: [PATCH] Change recommended operation IDL syntax The old operation syntax is now deprecated in favor of a syntax that's more consistent with the rest of the IDL. The following operation, operation Foo(Input) -> Output errors[X, Y, Z] Is now defined as: operation Foo { input: Input, output: Output, errors: [X, Y, Z] } Why? - This new syntax is more consistent with other shapes like resources, operations, structures, etc. This consistency makes it easier to implement parsers, formatters, etc. - Virtually all *actual* models define operations with errors. When an operation uses long input names, output, *and* defines errors, they either are one really long line or span multiple lines. How an operation definition was broken across multiple lines is something that has been approached with great inconsistency within AWS and Amazon. Using a syntax format that removes all ambiguity will help drive consistency in models, thereby making them easier to read. The old syntax is still supported, but no longer documented. A validation event is emitted when it is encountered. Support for the old syntax will be removed in Smithy 1.0. --- docs/source/quickstart.rst | 35 ++- docs/source/smithylexer.py | 3 +- docs/source/spec/aws-core.rst | 37 +++- docs/source/spec/aws-iam.rst | 8 +- docs/source/spec/core.rst | 206 ++++++++++++------ docs/source/spec/event-streams.rst | 29 ++- .../spec/http-protocol-compliance-tests.rst | 8 +- docs/source/spec/http.rst | 25 ++- docs/source/spec/language-specification.rst | 3 +- docs/source/spec/mqtt.rst | 13 +- .../apigateway/effective-authorizers.smithy | 12 +- .../traits/iam/invalid-condition-keys.smithy | 2 +- .../aws/traits/iam/required-actions.smithy | 2 +- .../iam/successful-condition-keys.smithy | 11 +- .../smithy/aws/traits/required-actions.smithy | 2 +- .../smithy/cli/commands/valid-model.smithy | 5 +- .../smithy/model/loader/IdlModelLoader.java | 38 +++- .../smithy/model/knowledge/bottom-up.smithy | 10 +- ...ations.json => deprecated-operations.json} | 0 ...ns.smithy => deprecated-operations.smithy} | 0 .../model/loader/valid/main-test.smithy | 21 +- .../model/selector/neighbor-test.smithy | 6 +- .../model/selector/path-to-member.smithy | 5 +- .../testsuite/dropped-mqtt-headers.smithy | 5 +- .../mqtt/traits/testsuite/job-service.smithy | 76 +++++-- .../mqtt-operations-with-errors.smithy | 10 +- .../traits/testsuite/mqtt-topic-labels.smithy | 18 +- .../testsuite/publish-with-eventstream.smithy | 4 +- .../subscribe-input-missing-label.smithy | 5 +- .../testsuite/subscribe-missing-output.smithy | 2 +- .../subscribe-operation-initial-event.smithy | 4 +- ...ribe-operation-missing-event-stream.smithy | 4 +- .../traits/testsuite/topic-conflicts.smithy | 26 ++- .../fromsmithy/mappers/greedy-labels.smithy | 4 +- .../fromsmithy/mappers/prefix-headers.smithy | 5 +- .../fromsmithy/mappers/small-service.smithy | 4 +- .../mappers/streaming-service.smithy | 4 +- .../errorfiles/all-request-features.smithy | 4 +- .../errorfiles/all-response-features.smithy | 4 +- .../errorfiles/detects-duplicate-ids.smithy | 13 +- .../errorfiles/detects-invalid-params.smithy | 10 +- .../errorfiles/timestamp-validation.smithy | 4 +- .../protocoltests/traits/say-goodbye.smithy | 4 +- .../protocoltests/traits/say-hello.smithy | 4 +- 44 files changed, 502 insertions(+), 193 deletions(-) rename smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/{operations.json => deprecated-operations.json} (100%) rename smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/{operations.smithy => deprecated-operations.smithy} (100%) diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst index 6b3cee281ee..4b37e2b0730 100644 --- a/docs/source/quickstart.rst +++ b/docs/source/quickstart.rst @@ -307,7 +307,11 @@ Let's define the operation used to "read" a ``City``. .. code-tab:: smithy @readonly - operation GetCity(GetCityInput) -> GetCityOutput errors [NoSuchResource] + operation GetCity { + input: GetCityInput, + output: GetCityOutput, + errors: [NoSuchResource] + } structure GetCityInput { // "cityId" provides the identifier for the resource and @@ -460,7 +464,10 @@ cities, so there's no way we could provide a City identifier. // sets default pagination configuration settings on each operation. @paginated(items: "items") @readonly - operation ListCities(ListCitiesInput) -> ListCitiesOutput + operation ListCities { + input: ListCitiesInput, + output: ListCitiesOutput + } structure ListCitiesInput { nextToken: String, @@ -622,7 +629,9 @@ service. } @readonly - operation GetCurrentTime() -> GetCurrentTimeOutput + operation GetCurrentTime { + output: GetCurrentTimeOutput + } structure GetCurrentTimeOutput { @required @@ -720,7 +729,11 @@ Complete example string CityId @readonly - operation GetCity(GetCityInput) -> GetCityOutput errors [NoSuchResource] + operation GetCity { + input: GetCityInput, + output: GetCityOutput, + errors: [NoSuchResource] + } structure GetCityInput { // "cityId" provides the identifier for the resource and @@ -760,7 +773,10 @@ Complete example // return truncated results. @readonly @paginated(items: "items") - operation ListCities(ListCitiesInput) -> ListCitiesOutput + operation ListCities { + input: ListCitiesInput, + output: ListCitiesOutput + } structure ListCitiesInput { nextToken: String, @@ -790,7 +806,9 @@ Complete example } @readonly - operation GetCurrentTime() -> GetCurrentTimeOutput + operation GetCurrentTime { + output: GetCurrentTimeOutput + } structure GetCurrentTimeOutput { @required @@ -798,7 +816,10 @@ Complete example } @readonly - operation GetForecast(GetForecastInput) -> GetForecastOutput + operation GetForecast { + input: GetForecastInput, + output: GetForecastOutput + } // "cityId" provides the only identifier for the resource since // a Forecast doesn't have its own. diff --git a/docs/source/smithylexer.py b/docs/source/smithylexer.py index d834fdea995..b946eb6c820 100644 --- a/docs/source/smithylexer.py +++ b/docs/source/smithylexer.py @@ -32,8 +32,7 @@ class SmithyLexer(RegexLexer): (r'///.*$', Comment.Multiline), (r'//.*$', Comment), (r'@[0-9a-zA-Z\.#-]*', Name.Decorator), - (r'(->|=)', Name.Decorator), - (r'errors', Name.Decorator), + (r'(=)', Name.Decorator), (r'^(\$version)(:)(.+)', bygroups(Keyword.Declaration, Name.Decorator, Name.Class)), (r'^(namespace)(\s+' + identifier + r')\b', bygroups(Keyword.Declaration, Name.Class)), (r'^(use|byte|short|integer|long|float|' diff --git a/docs/source/spec/aws-core.rst b/docs/source/spec/aws-core.rst index 96c0fdb9359..2d04005e8ca 100644 --- a/docs/source/spec/aws-core.rst +++ b/docs/source/spec/aws-core.rst @@ -752,7 +752,10 @@ plane unless an operation or resource is marked with the use aws.api#controlPlane @controlPlane - operation PutThings(PutThingsInput) -> PutThingsOutput + operation PutThings { + input: PutThingsInput, + output: PutThingsOutput + } .. code-tab:: json @@ -803,7 +806,10 @@ plane unless an operation or resource is marked with the use aws.api#controlPlane @dataPlane - operation PutThings(PutThingsInput) -> PutThingsOutput + operation PutThings { + input: PutThingsInput, + output: PutThingsOutput + } .. code-tab:: json @@ -859,7 +865,10 @@ operation MUST NOT be used as part of the request signature calculation: use aws.api#unsignedPayload @unsignedPayload - operation PutThings(PutThingsInput) -> PutThingsOutput + operation PutThings { + input: PutThingsInput, + output: PutThingsOutput + } .. code-tab:: json @@ -891,7 +900,10 @@ only when using the "aws.v4" authentication scheme: use aws.api#unsignedPayload @unsignedPayload(["aws.v4"]) - operation PutThings(PutThingsInput) -> PutThingsOutput + operation PutThings { + input: PutThingsInput, + output: PutThingsOutput + } .. code-tab:: json @@ -949,7 +961,7 @@ when serializing an INPUT. For example, given the following Smithy model: bar: String } - .. code-tabe:: json + .. code-tab:: json { "smithy": "0.5.0", @@ -970,7 +982,7 @@ when serializing an INPUT. For example, given the following Smithy model: The serialization of this structure as an input is: -.. code-block:: +:: MyStruct.bar=baz @@ -1108,9 +1120,11 @@ using an ``clientEndpointDiscoveryId``. operations: [DescribeEndpoints, GetObject] } - operation DescribeEndpoints(DescribeEndpointsInput) - -> DescribeEndpointsOutput - errors [InvalidEndpointError] + operation DescribeEndpoints { + input: DescribeEndpointsInput, + output: DescribeEndpointsOutput, + errors: [InvalidEndpointError] + } @error("client") @httpError(421) @@ -1140,7 +1154,10 @@ using an ``clientEndpointDiscoveryId``. } @aws.api#clientDiscoveredEndpoint(required: true) - operation GetObject(GetObjectInput) -> GetObjectOutput + operation GetObject { + input: GetObjectInput, + output: GetObjectOutput + } structure GetObjectInput { @clientEndpointDiscoveryId diff --git a/docs/source/spec/aws-iam.rst b/docs/source/spec/aws-iam.rst index da5003230fe..2c5b0638bfe 100644 --- a/docs/source/spec/aws-iam.rst +++ b/docs/source/spec/aws-iam.rst @@ -46,7 +46,7 @@ Value type use aws.iam#actionPermissionDescription @actionPermissionDescription("This will allow the user to Foo.") - operation FooOperation() + operation FooOperation {} .. code-tab:: json @@ -107,7 +107,7 @@ The following example's ``MyResource`` resource has the } @conditionKeys(["aws:region"]) - operation MyOperation + operation MyOperation {} .. code-tab:: json @@ -434,7 +434,7 @@ operation for it to complete successfully. } @requiredActions(["otherservice:OtherOperation"]) - operation MyOperation + operation MyOperation {} .. code-tab:: json @@ -530,7 +530,7 @@ Given the following model, } @conditionKeys(["aws:region"]) - operation MyOperation + operation MyOperation {} .. code-tab:: json diff --git a/docs/source/spec/core.rst b/docs/source/spec/core.rst index 3302363a466..e8510e6928a 100644 --- a/docs/source/spec/core.rst +++ b/docs/source/spec/core.rst @@ -1072,7 +1072,9 @@ that do not fit within a resource hierarchy. } @readonly - operation GetServerTime() -> GetServerTimeOutput + operation GetServerTime { + output: GetServerTimeOutput + } .. code-tab:: json @@ -1163,6 +1165,21 @@ an API operation. Operation shapes are bound to :ref:`resource ` shapes and :ref:`service ` shapes. Operation shapes are defined using the :token:`operation_statement`. +An operation is an object that supports the following key-value pairs: + +.. list-table:: + :header-rows: 1 + :widths: 10 90 + + * - Type + - Description + * - :ref:`input ` + - The optional input structure of the operation. + * - :ref:`output ` + - The optional output structure of the operation. + * - :ref:`errors ` + - The optional list of errors the operation can return. + The following example defines an operation shape that accepts an input structure named ``Input``, returns an output structure named ``Output``, and can potentially return the ``NotFound`` or ``BadRequest`` @@ -1172,7 +1189,11 @@ can potentially return the ``NotFound`` or ``BadRequest`` .. code-tab:: smithy - operation MyOperation(Input) -> Output errors [NotFound, BadRequest] + operation MyOperation { + input: Input, + output: Output, + errors: [NotFound, BadRequest] + } .. code-tab:: json @@ -1214,7 +1235,9 @@ named ``Input``: .. code-tab:: smithy - operation MyOperation(Input) + operation MyOperation { + input: Input + } .. code-tab:: json @@ -1230,26 +1253,6 @@ named ``Input``: } } -The input of an operation can be omitted with empty parenthesis after the -shape name. The following example defines an operation that accepts no -input and returns no output: - -.. tabs:: - - .. code-tab:: smithy - - operation MyOperation() - - .. code-tab:: json - - { - "smithy": "0.5.0", - "shapes": { - "smithy.example#MyOperation": { - "type": "operation" - } - } - } .. _operation-output: @@ -1266,7 +1269,9 @@ structure named ``Output``: .. code-tab:: smithy - operation MyOperation() -> Output + operation MyOperation { + output: Output + } .. code-tab:: json @@ -1282,15 +1287,16 @@ structure named ``Output``: } } + .. _operation-errors: Operation errors ```````````````` -The errors of an operation is an optional, comma-separated, list of shape IDs -that MUST target structure shapes that are marked with the -:ref:`error-trait`. Errors defined on an operation are errors that can -potentially occur when calling an operation. +The errors of an operation is an optional array of shape IDs that MUST +target structure shapes that are marked with the :ref:`error-trait`. Errors +defined on an operation are errors that can potentially occur when calling +an operation. The following example defines an operation shape that accepts no input, returns no output, and can potentially return the @@ -1300,7 +1306,9 @@ returns no output, and can potentially return the .. code-tab:: smithy - operation MyOperation() errors [NotFound, BadRequest] + operation MyOperation { + errors: [NotFound, BadRequest] + } .. code-tab:: json @@ -1321,6 +1329,7 @@ returns no output, and can potentially return the } } + .. _resource: Resource @@ -1652,7 +1661,10 @@ For example, given the following model, } @readonly - operation GetForecast(GetForecastInput) -> GetForecastOutput + operation GetForecast { + input: GetForecastInput, + output: GetForecastOutput + } structure GetForecastInput { @required @@ -1739,8 +1751,10 @@ Given the following model, operations: [BatchPutForecasts], } - operation BatchPutForecasts(BatchPutForecastsInput) - -> BatchPutForecastsOutput + operation BatchPutForecasts { + input: BatchPutForecastsInput, + output: BatchPutForecastsOutput + } structure BatchPutForecastsInput { @required @@ -1821,8 +1835,10 @@ For example, given the following, } @readonly - operation GetHistoricalForecast(GetHistoricalForecastInput) - -> GetHistoricalForecastOutput + operation GetHistoricalForecast { + input: GetHistoricalForecastInput, + output: GetHistoricalForecastOutput + } structure GetHistoricalForecastInput { @required @@ -1886,7 +1902,10 @@ The following snippet defines the ``PutForecast`` operation. .. code-block:: smithy - operation PutForecast(PutForecastInput) -> PutForecastOutput + operation PutForecast { + input: PutForecastInput, + output: PutForecastOutput + } @idempotent structure PutForecastInput { @@ -1914,10 +1933,16 @@ The following snippet defines the ``CreateForecast`` operation. .. code-block:: smithy - operation CreateForecast(CreateForecastInput) -> CreateForecastOutput + operation CreateForecast { + input: CreateForecastInput, + output: CreateForecastOutput + } @collection - operation CreateForecast(CreateForecastInput) -> CreateForecastOutput + operation CreateForecast { + input: CreateForecastInput, + output: CreateForecastOutput + } structure CreateForecastInput { // No identifier is provided by the client, so the service is @@ -1946,9 +1971,11 @@ For example: .. code-block:: smithy @readonly - operation GetForecast(GetForecastInput) - -> GetForecastOutput - errors [ResourceNotFound] + operation GetForecast { + input: GetForecastInput, + output: GetForecastOutput, + errors: [ResourceNotFound] + } structure GetForecastInput { @required @@ -1973,9 +2000,11 @@ For example: .. code-block:: smithy - operation UpdateForecast(UpdateForecastInput) - -> UpdateForecastOutput - errors [ResourceNotFound] + operation UpdateForecast { + input: UpdateForecastInput, + output: UpdateForecastOutput, + errors: [ResourceNotFound] + } structure UpdateForecastInput { @required @@ -2003,9 +2032,11 @@ For example: .. code-block:: smithy @idempotent - operation DeleteForecast(DeleteForecastInput) - -> DeleteForecastOutput - errors [ResourceNotFound] + operation DeleteForecast { + input: DeleteForecastInput, + output: DeleteForecastOutput, + errors: [ResourceNotFound] + } structure DeleteForecastInput { @required @@ -2034,7 +2065,10 @@ For example: .. code-block:: smithy @collection @readonly @paginated - operation ListForecasts(ListForecastsInput) -> ListForecastsOutput + operation ListForecasts { + input: ListForecastsInput, + output: ListForecastsOutput + } structure ListForecastsInput { maxResults: Integer, @@ -3886,7 +3920,9 @@ member if and only if the member is not explicitly provided. .. code-tab:: smithy - operation AllocateWidget(AllocateWidgetInput) + operation AllocateWidget { + input: AllocateWidgetInput + } structure AllocateWidgetInput { @idempotencyToken @@ -3915,7 +3951,10 @@ Conflicts with .. code-tab:: smithy @idempotent - operation GetSomething(DeleteSomething) -> DeleteSomethingOuput + operation GetSomething { + input: DeleteSomething, + output: DeleteSomethingOutput + } .. note:: @@ -3942,7 +3981,10 @@ Conflicts with .. code-tab:: smithy @readonly - operation GetSomething(GetSomethingInput) -> GetSomethingOutput + operation GetSomething { + input: GetSomethingInput, + output: GetSomethingOutput + } .. _retryable-trait: @@ -4071,7 +4113,10 @@ explicitly on the operation. @collection @readonly @paginated(inputToken: "nextToken", outputToken: "nextToken", pageSize: "maxResults", items: "foos") - operation GetFoos(GetFoosInput) -> GetFoosOutput + operation GetFoos { + input: GetFoosInput, + output: GetFoosOutput + } structure GetFoosInput { maxResults: Integer, @@ -4169,7 +4214,10 @@ settings from a service. } @collection @readonly @paginated(items: "foos") - operation GetFoos(GetFoosInput) -> GetFoosOutput + operation GetFoos { + input: GetFoosInput, + output: GetFoosOutput + } .. code-tab:: json @@ -4228,7 +4276,10 @@ wrapper where the output token and items are referenced by paths. @readonly @paginated(inputToken: "nextToken", outputToken: "result.nextToken", pageSize: "maxResults", items: "result.foos") - operation GetFoos(GetFoosInput) -> GetFoosOutput + operation GetFoos { + input: GetFoosInput, + output: GetFoosOutput + } structure GetFoosInput { maxResults: Integer, @@ -4586,7 +4637,11 @@ match for the name of the resource identifier. } @readonly - operation GetFile(GetFileInput) -> GetFileOutput errors [NoSuchResource] + operation GetFile { + input: GetFileInput, + output: GetFileOutput, + errors: [NoSuchResource] + } structure GetFileInput { @required @@ -4798,11 +4853,11 @@ The following example defines two operations: // This operation is configured to either be unauthenticated // or to use http-basic. It is not expected to support http-digest. @auth(["none", "http-basic"]) - operation OperationA() + operation OperationA {} // This operation defines no auth, so it is expected to support the auth // defined on the service: http-basic and http-digest. - operation OperationB() + operation OperationB {} .. code-tab:: json @@ -4875,9 +4930,9 @@ protocols can define different authentication schemes for each protocol. } @auth(["http-digest", "x.509"]) - operation OperationA() + operation OperationA {} - operation OperationB() + operation OperationB {} .. code-tab:: json @@ -5229,7 +5284,10 @@ These values use the same semantics and format as .. code-tab:: smithy @readonly - operation MyOperation(MyOperationInput) -> MyOperationOutput + operation MyOperation { + input: MyOperationInput, + output: MyOperationOutput + } apply MyOperation @examples([ { @@ -5423,7 +5481,10 @@ The following example defines an operation that uses a custom endpoint: @readonly @endpoint(hostPrefix: "{foo}.data.") - operation GetStatus(GetStatusInput) -> GetStatusOutput + operation GetStatus { + input: GetStatusInput, + output: GetStatusOutput + } structure GetStatusInput { @required @@ -5486,7 +5547,10 @@ Given the following operation, @readonly @endpoint(hostPrefix: "{foo}.data.") - operation GetStatus(GetStatusInput) -> GetStatusOutput + operation GetStatus { + input: GetStatusInput, + output: GetStatusOutput + } structure GetStatusInput { @required @@ -5548,7 +5612,10 @@ Given the following operation, @readonly @endpoint(hostPrefix: "{foo}-{bar}.data.") - operation GetStatus(GetStatusInput) -> GetStatusOutput + operation GetStatus { + input: GetStatusInput, + output: GetStatusOutput + } structure GetStatusInput { @required @@ -5620,7 +5687,10 @@ invalid because the ``{foo}`` and ``{bar}`` labels are adjacent: @readonly @endpoint(hostPrefix: "{foo}{bar}.data.") - operation GetStatus(GetStatusInput) -> GetStatusOutput + operation GetStatus { + input: GetStatusInput, + output: GetStatusOutput + } .. code-tab:: json @@ -5678,7 +5748,10 @@ Given the following operation, @readonly @endpoint(hostPrefix: "{foo}.data.") @http(method: "GET", uri: "/status") - operation GetStatus(GetStatusInput) -> GetStatusOutput + operation GetStatus { + input: GetStatusInput, + output: GetStatusOutput + } structure GetStatusInput { @required @@ -5766,7 +5839,10 @@ to an operation marked with the :ref:`endpoint-trait` will be ignored. @readonly @endpoint(hostPrefix: "{foo}.data") - operation GetStatus(GetStatusInput) -> GetStatusOutput + operation GetStatus { + input: GetStatusInput, + output: GetStatusOutput + } structure GetStatusInput { @required diff --git a/docs/source/spec/event-streams.rst b/docs/source/spec/event-streams.rst index 008610433a7..9977f247432 100644 --- a/docs/source/spec/event-streams.rst +++ b/docs/source/spec/event-streams.rst @@ -42,7 +42,9 @@ stream in its input: namespace smithy.example - operation PublishMessages(PublishMessagesInput) + operation PublishMessages { + input: PublishMessagesInput + } structure PublishMessagesInput { room: String, @@ -102,7 +104,9 @@ stream in its output: namespace smithy.example - operation SubscribeToMovements() -> SubscribeToMovementsOutput + operation SubscribeToMovements { + output: SubscribeToMovementsOutput + } structure SubscribeToMovementsOutput { @eventStream @@ -190,7 +194,9 @@ stream in its input by referencing a member that targets a union: namespace smithy.example - operation PublishMessages(PublishMessagesInput) + operation PublishMessages { + input: PublishMessagesInput + } structure PublishMessagesInput { room: String, @@ -268,7 +274,9 @@ stream in its output: namespace smithy.example - operation SubscribeToMovements() -> SubscribeToMovementsOutput + operation SubscribeToMovements { + output: SubscribeToMovementsOutput + } structure SubscribeToMovementsOutput { @eventStream @@ -354,7 +362,9 @@ on the name of an event. For example, given the following event stream, namespace smithy.example - operation SubscribeToEvents() -> SubscribeToEventsOutput + operation SubscribeToEvents { + output: SubscribeToEventsOutput + } structure SubscribeToEventsOutput { @eventStream @@ -421,7 +431,9 @@ service, followed by the events sent in the payload of the HTTP message. namespace smithy.example @http(method: "POST", uri: "/messages/{room}") - operation PublishMessages(PublishMessagesInput) + operation PublishMessages { + input: PublishMessagesInput + } structure PublishMessagesInput { @httpLabel @@ -509,7 +521,10 @@ message. namespace smithy.example @http(method: "GET", uri: "/messages/{room}") - operation SubscribeToMessages(SubscribeToMessagesInput) -> SubscribeToMessagesOutput + operation SubscribeToMessages { + input: SubscribeToMessagesInput, + output: SubscribeToMessagesOutput + } structure SubscribeToMessagesInput { @httpLabel diff --git a/docs/source/spec/http-protocol-compliance-tests.rst b/docs/source/spec/http-protocol-compliance-tests.rst index 1f135f343d8..8dd288b8562 100644 --- a/docs/source/spec/http-protocol-compliance-tests.rst +++ b/docs/source/spec/http-protocol-compliance-tests.rst @@ -230,7 +230,9 @@ that uses :ref:`HTTP binding traits `. bodyMediaType: "application/json" } ]) - operation SayHello(SayHelloInput) + operation SayHello { + input: SayHelloInput + } structure SayHelloInput { @httpHeader("X-Greeting") @@ -418,7 +420,9 @@ that uses :ref:`HTTP binding traits `. } } ]) - operation SayGoodbye() -> SayGoodbyeOutput + operation SayGoodbye { + output: SayGoodbyeOutput + } structure SayGoodbyeOutput { @httpHeader("X-Farewell") diff --git a/docs/source/spec/http.rst b/docs/source/spec/http.rst index f1ffbc76df8..78d4fe47540 100644 --- a/docs/source/spec/http.rst +++ b/docs/source/spec/http.rst @@ -62,7 +62,9 @@ The following example defines an operation that uses HTTP bindings: @idempotent @http(method: "PUT", uri: "/{bucketName}/{key}", code: 200) - operation PutObject(PutObjectInput) + operation PutObject { + input: PutObjectInput + } structure PutObjectInput { // Sent in the URI label named "key". @@ -138,7 +140,9 @@ constraints: @readonly @http(method: "GET", uri: "/foo/{baz}") - operation GetService() -> GetServiceOutput + operation GetService { + output: GetServiceOutput + } Literal character sequences @@ -621,7 +625,10 @@ Serialization rules: @readonly @http(method: "GET", uri: "/{foo}") - operation GetStatus(GetStatusInput) -> GetStatusOutput + operation GetStatus { + input: GetStatusInput, + output: GetStatusOutput + } structure GetStatusInput { @required @@ -723,7 +730,9 @@ Given the following Smithy model: @readonly @http(method: "GET", uri: "/myOperation") - operation MyOperation(MyOperationInput) + operation MyOperation { + input: MyOperationInput + } structure MyOperationInput { @httpPrefixHeaders("X-Foo-") @@ -934,7 +943,9 @@ and HTTP bindings: namespace smithy.example @http(method: "POST", uri: "/messages") - operation PublishMessages(PublishMessagesInput) + operation PublishMessages { + input: PublishMessagesInput + } structure PublishMessagesInput { @httpPayload @@ -995,7 +1006,9 @@ marked with the ``httpPayload`` trait: namespace smithy.example @http(method: "POST", uri: "/messages") - operation InvalidOperation(InvalidOperationInput) + operation InvalidOperation { + input: InvalidOperationInput + } structure InvalidOperationInput { @eventStream diff --git a/docs/source/spec/language-specification.rst b/docs/source/spec/language-specification.rst index 08bd6b35e31..31bfec8c164 100644 --- a/docs/source/spec/language-specification.rst +++ b/docs/source/spec/language-specification.rst @@ -231,8 +231,7 @@ be defined after a *current namespace* has been defined using a :/ `simple_shape` service_statement :"service" `identifier` `node_object` resource_statement :"resource" `identifier` `node_object` - operation_statement :"operation" `identifier` "(" [`shape_id`] ")" `operation_results` - operation_results :["->" `shape_id`] ["errors" "[" [`shape_id` *("," `shape_id`)] "]"] + operation_statement :"operation" `identifier` `node_object` structure_statement :"structure" `structured_body` union_statement :"union" `structured_body` structured_body :`identifier` "{" [`structured_member` *("," `structured_member`)] "}" diff --git a/docs/source/spec/mqtt.rst b/docs/source/spec/mqtt.rst index 2495706970e..f90ae47d253 100644 --- a/docs/source/spec/mqtt.rst +++ b/docs/source/spec/mqtt.rst @@ -95,7 +95,9 @@ and ``{second}``, in the MQTT topic template: use smithy.mqtt#topicLabel @publish("{first}/{second}") - operation ExampleOperation(ExampleOperationInput) + operation ExampleOperation { + input: ExampleOperationInput + } structure ExampleOperationInput { @required @@ -205,7 +207,9 @@ The following example defines an operation that publishes messages to the use smithy.mqtt#topicLabel @publish("foo/{bar}") - operation PostFoo(PostFooInput) + operation PostFoo { + input: PostFooInput + } structure PostFooInput { @required @@ -317,7 +321,10 @@ topic using a :ref:`single-event event stream `: use smithy.mqtt#topicLabel @subscribe("events/{id}") - operation SubscribeForEvents(SubscribeForEventsInput) -> SubscribeForEventsOutput + operation SubscribeForEvents { + input: SubscribeForEventsInput, + output: SubscribeForEventsOutput + } structure SubscribeForEventsInput { @required diff --git a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/apigateway/effective-authorizers.smithy b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/apigateway/effective-authorizers.smithy index 8af3b1ab2e1..59f6a7c0e46 100644 --- a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/apigateway/effective-authorizers.smithy +++ b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/apigateway/effective-authorizers.smithy @@ -12,11 +12,11 @@ service ServiceA { } // Inherits the authorizer of ServiceA -operation OperationA() +operation OperationA {} // Overrides the authorizer of ServiceA @aws.apigateway#authorizer("baz") -operation OperationB() +operation OperationB {} // Inherits the authorizer of ServiceA resource ResourceA { @@ -24,11 +24,11 @@ resource ResourceA { } // Inherits the authorizer of ServiceA -operation OperationC() +operation OperationC {} // Overrides the authorizer of ServiceA @aws.apigateway#authorizer("baz") -operation OperationD() +operation OperationD {} // Overrides the authorizer of ServiceA @aws.apigateway#authorizer("baz") @@ -37,11 +37,11 @@ resource ResourceB { } // Inherits the authorizer of ResourceB -operation OperationE() +operation OperationE {} // Overrides the authorizer of ResourceB @aws.apigateway#authorizer("foo") -operation OperationF() +operation OperationF {} @protocols([{name: "aws-rest-json", auth: ["aws.v4"]}]) diff --git a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/invalid-condition-keys.smithy b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/invalid-condition-keys.smithy index eab2f42c1be..8f34066b46e 100644 --- a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/invalid-condition-keys.smithy +++ b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/invalid-condition-keys.smithy @@ -9,4 +9,4 @@ service MyService { } @aws.iam#conditionKeys(["foo:qux"]) -operation Operation() +operation Operation {} diff --git a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/required-actions.smithy b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/required-actions.smithy index e5eb544e68a..ecc74c034e8 100644 --- a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/required-actions.smithy +++ b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/required-actions.smithy @@ -2,4 +2,4 @@ $version: "0.5.0" namespace smithy.example @aws.iam#requiredActions(["iam:PassRole", "ec2:RunInstances"]) -operation MyOperation() +operation MyOperation {} diff --git a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/successful-condition-keys.smithy b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/successful-condition-keys.smithy index 6549d296de6..2873a6b654a 100644 --- a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/successful-condition-keys.smithy +++ b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/iam/successful-condition-keys.smithy @@ -10,7 +10,7 @@ service MyService { } @aws.iam#conditionKeys(["aws:accountId", "foo:baz"]) -operation Operation1() +operation Operation1 {} @aws.iam#conditionKeys(["aws:accountId", "foo:baz"]) resource Resource1 { @@ -30,7 +30,9 @@ resource Resource2 { } @readonly -operation GetResource2(GetResource2Input) +operation GetResource2 { + input: GetResource2Input +} structure GetResource2Input { @required @@ -44,7 +46,10 @@ structure GetResource2Input { string FooString @readonly -operation ListResource2(ListResource2Input) -> ListResource2Output +operation ListResource2 { + input: ListResource2Input, + output: ListResource2Output +} structure ListResource2Input { @required diff --git a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/required-actions.smithy b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/required-actions.smithy index 253ef47c317..7bb72732074 100644 --- a/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/required-actions.smithy +++ b/smithy-aws-traits/src/test/resources/software/amazon/smithy/aws/traits/required-actions.smithy @@ -1,4 +1,4 @@ namespace smithy.example @aws.api#requiredActions(["iam:PassRole", "ec2:RunInstances"]) -operation MyOperation() +operation MyOperation {} diff --git a/smithy-cli/src/test/resources/software/amazon/smithy/cli/commands/valid-model.smithy b/smithy-cli/src/test/resources/software/amazon/smithy/cli/commands/valid-model.smithy index f06701bfe89..4205635c31d 100644 --- a/smithy-cli/src/test/resources/software/amazon/smithy/cli/commands/valid-model.smithy +++ b/smithy-cli/src/test/resources/software/amazon/smithy/cli/commands/valid-model.smithy @@ -8,7 +8,10 @@ resource Foo { string FooId @readonly -operation GetFoo(GetFooInput) -> GetFooOutput +operation GetFoo { + input: GetFooInput, + output: GetFooOutput +} structure GetFooInput { @required diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/loader/IdlModelLoader.java b/smithy-model/src/main/java/software/amazon/smithy/model/loader/IdlModelLoader.java index 9cace8d1e5a..2e10cef4c09 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/loader/IdlModelLoader.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/loader/IdlModelLoader.java @@ -112,6 +112,9 @@ final class IdlModelLoader { // Valid map keys. private static final Collection MAP_KEYS = ListUtils.of("key", "value"); + // Valid operation properties. + private static final Collection OPERATION_PROPERTY_NAMES = ListUtils.of("input", "output", "errors"); + private final String filename; private final SmithyModelLexer lexer; private final LoaderVisitor visitor; @@ -842,8 +845,37 @@ private void parseOperation() { OperationShape.Builder builder = OperationShape.builder().id(id).source(sourceLocation); visitor.onShape(builder); - // Parse the optionally present input target. - expect(LPAREN); + Token opening = expect(LPAREN, LBRACE); + if (opening.type == LPAREN) { + parseDeprecatedOperationSyntax(builder); + } else { + ObjectNode node = parseObjectNode(opening.getSourceLocation(), RBRACE); + node.expectNoAdditionalProperties(OPERATION_PROPERTY_NAMES); + node.getStringMember("input").ifPresent(input -> { + visitor.onShapeTarget(input.getValue(), input, builder::input); + }); + node.getStringMember("output").ifPresent(output -> { + visitor.onShapeTarget(output.getValue(), output, builder::output); + }); + node.getArrayMember("errors").ifPresent(errors -> { + for (StringNode value : errors.getElementsAs(StringNode.class)) { + visitor.onShapeTarget(value.getValue(), value, builder::addError); + } + }); + } + + expectNewline(); + } + + private void parseDeprecatedOperationSyntax(OperationShape.Builder builder) { + visitor.onError(ValidationEvent.builder() + .eventId(Validator.MODEL_ERROR) + .sourceLocation(builder.getSourceLocation()) + .shapeId(builder.getId()) + .message("Deprecated IDL syntax detected for operation definition") + .severity(Severity.WARNING) + .build()); + Token next = expect(RPAREN, UNQUOTED); if (next.type == UNQUOTED) { visitor.onShapeTarget(next.lexeme, next, builder::input); @@ -873,7 +905,5 @@ private void parseOperation() { } expect(RBRACKET); } - - expectNewline(); } } diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/knowledge/bottom-up.smithy b/smithy-model/src/test/resources/software/amazon/smithy/model/knowledge/bottom-up.smithy index 44315f4e29e..10d7d622ba7 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/knowledge/bottom-up.smithy +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/knowledge/bottom-up.smithy @@ -6,14 +6,14 @@ service Example { resources: [Resource1, Resource2] } -operation ServiceOperation() +operation ServiceOperation {} resource Resource1 { operations: [Resource1Operation], resources: [Resource1_1, Resource1_2] } -operation Resource1Operation() +operation Resource1Operation {} resource Resource1_2 {} @@ -23,18 +23,18 @@ resource Resource1_1 { resources: [Resource1_1_1, Resource1_1_2] } -operation Resource1_1_Operation() +operation Resource1_1_Operation {} resource Resource1_1_1 { operations: [Resource1_1_1_Operation], } -operation Resource1_1_1_Operation() +operation Resource1_1_1_Operation {} resource Resource1_1_2 { operations: [Resource1_1_2_Operation], } -operation Resource1_1_2_Operation() +operation Resource1_1_2_Operation {} resource Resource2 {} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/operations.json b/smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/deprecated-operations.json similarity index 100% rename from smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/operations.json rename to smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/deprecated-operations.json diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/operations.smithy b/smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/deprecated-operations.smithy similarity index 100% rename from smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/operations.smithy rename to smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/deprecated-operations.smithy diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/main-test.smithy b/smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/main-test.smithy index 684b2522297..a6973f5c6de 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/main-test.smithy +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/loader/valid/main-test.smithy @@ -23,14 +23,20 @@ resource Forecast { string CityId @readonly -operation GetCurrentTime() -> GetCurrentTimeOutput +operation GetCurrentTime { + output: GetCurrentTimeOutput +} structure GetCurrentTimeOutput { time: smithy.api#Timestamp } @readonly -operation GetForecast(GetForecastInput) -> GetForecastOutput errors [NoSuchResource] +operation GetForecast { + input: GetForecastInput, + output: GetForecastOutput, + errors: [NoSuchResource] +} structure GetForecastInput { @required cityId: CityId @@ -43,7 +49,11 @@ structure GetForecastOutput { } @readonly -operation GetCity(GetCityInput) -> GetCityOutput errors [NoSuchResource] +operation GetCity { + input: GetCityInput, + output: GetCityOutput, + errors: [NoSuchResource] +} structure GetCityInput { @required cityId: CityId @@ -57,7 +67,10 @@ structure GetCityOutput { @readonly @paginated(inputToken: "nextToken", outputToken: "nextToken", pageSize: "pageSize", items: "items") -operation ListCities(ListCitiesInput) -> ListCitiesOutput +operation ListCities { + input: ListCitiesInput, + output: ListCitiesOutput +} structure ListCitiesInput { nextToken: smithy.api#String, diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/selector/neighbor-test.smithy b/smithy-model/src/test/resources/software/amazon/smithy/model/selector/neighbor-test.smithy index 9cdb75c761c..9cc844c603c 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/selector/neighbor-test.smithy +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/selector/neighbor-test.smithy @@ -1,6 +1,10 @@ namespace smithy.example -operation Operation(Input) -> Output errors [Error] +operation Operation { + input: Input, + output: Output, + errors: [Error] +} structure Input { foo: smithy.api#String, diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/selector/path-to-member.smithy b/smithy-model/src/test/resources/software/amazon/smithy/model/selector/path-to-member.smithy index 8ffae6506e4..2b4d867070e 100644 --- a/smithy-model/src/test/resources/software/amazon/smithy/model/selector/path-to-member.smithy +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/selector/path-to-member.smithy @@ -1,6 +1,9 @@ namespace smithy.example -operation Operation(Input) -> Output +operation Operation { + input: Input, + output: Output +} structure Input { foo: String, diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/dropped-mqtt-headers.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/dropped-mqtt-headers.smithy index dcd0f2ca996..f5bf7498795 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/dropped-mqtt-headers.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/dropped-mqtt-headers.smithy @@ -4,7 +4,10 @@ namespace smithy.example @smithy.mqtt#subscribe("events") -operation Foo(FooInput) -> FooOutput +operation Foo { + input: FooInput, + output: FooOutput +} structure FooInput {} diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/job-service.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/job-service.smithy index a3c6cb4193d..a72ab4e3b76 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/job-service.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/job-service.smithy @@ -62,17 +62,23 @@ string RejectedErrorCode @smithy.mqtt#publish("$aws/things/{thingName}/jobs/get") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-getpendingjobexecutions") -operation PublishGetPendingJobExecutions(GetPendingJobExecutionsRequest) +operation PublishGetPendingJobExecutions { + input: GetPendingJobExecutionsRequest +} @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/get/accepted") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-getpendingjobexecutions") -operation SubscribeToGetPendingJobExecutionsAccepted(GetPendingJobExecutionsSubscriptionRequest) - -> GetPendingJobExecutionsSubscriptionResponse +operation SubscribeToGetPendingJobExecutionsAccepted { + input: GetPendingJobExecutionsSubscriptionRequest, + output: GetPendingJobExecutionsSubscriptionResponse +} @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/get/rejected") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-getpendingjobexecutions") -operation SubscribeToGetPendingJobExecutionsRejected(GetPendingJobExecutionsSubscriptionRequest) - -> RejectedResponse +operation SubscribeToGetPendingJobExecutionsRejected { + input: GetPendingJobExecutionsSubscriptionRequest, + output: RejectedResponse, +} structure GetPendingJobExecutionsRequest { @required @@ -119,17 +125,23 @@ structure JobExecutionSummary { @smithy.mqtt#publish("$aws/things/{thingName}/jobs/start-next") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-startnextpendingjobexecution") -operation PublishStartNextPendingJobExecution(StartNextPendingJobExecutionRequest) +operation PublishStartNextPendingJobExecution { + input: StartNextPendingJobExecutionRequest +} @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/start-next/accepted") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-startnextpendingjobexecution") -operation SubscribeToStartNextPendingJobExecutionAccepted(StartNextPendingJobExecutionSubscriptionRequest) - -> StartNextPendingJobExecutionSubscriptionResponse +operation SubscribeToStartNextPendingJobExecutionAccepted { + input: StartNextPendingJobExecutionSubscriptionRequest, + output: StartNextPendingJobExecutionSubscriptionResponse +} @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/start-next/rejected") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-startnextpendingjobexecution") -operation SubscribeToStartNextPendingJobExecutionRejected(StartNextPendingJobExecutionSubscriptionRequest) - -> RejectedResponse +operation SubscribeToStartNextPendingJobExecutionRejected { + input: StartNextPendingJobExecutionSubscriptionRequest, + output: RejectedResponse +} structure StartNextPendingJobExecutionRequest { @required @@ -195,17 +207,23 @@ string JobStatus @smithy.mqtt#publish("$aws/things/{thingName}/jobs/{jobId}/get") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-describejobexecution") -operation PublishDescribeJobExecution(DescribeJobExecutionRequest) +operation PublishDescribeJobExecution { + input: DescribeJobExecutionRequest +} @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/{jobId}/get/accepted") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-describejobexecution") -operation SubscribeToDescribeJobExecutionAccepted(DescribeJobExecutionSubscriptionRequest) - -> DescribeJobExecutionSubscriptionResponse +operation SubscribeToDescribeJobExecutionAccepted { + input: DescribeJobExecutionSubscriptionRequest, + output: DescribeJobExecutionSubscriptionResponse +} @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/{jobId}/get/rejected") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-describejobexecution") -operation SubscribeToDescribeJobExecutionRejected(DescribeJobExecutionSubscriptionRequest) - -> RejectedResponse +operation SubscribeToDescribeJobExecutionRejected { + input: DescribeJobExecutionSubscriptionRequest, + output: RejectedResponse +} structure DescribeJobExecutionRequest { @required @@ -252,17 +270,23 @@ structure DescribeJobExecutionResponse { @smithy.mqtt#publish("$aws/things/{thingName}/jobs/{jobId}/update") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-updatejobexecution") -operation PublishUpdateJobExecution(UpdateJobExecutionRequest) +operation PublishUpdateJobExecution { + input: UpdateJobExecutionRequest +} @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/{jobId}/update/accepted") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-updatejobexecution") -operation SubscribeToUpdateJobExecutionAccepted(UpdateJobExecutionSubscriptionRequest) - -> UpdateJobExecutionSubscriptionResponse +operation SubscribeToUpdateJobExecutionAccepted { + input: UpdateJobExecutionSubscriptionRequest, + output: UpdateJobExecutionSubscriptionResponse +} @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/{jobId}/update/rejected") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-updatejobexecution") -operation SubscribeToUpdateJobExecutionRejected(UpdateJobExecutionSubscriptionRequest) - -> RejectedResponse +operation SubscribeToUpdateJobExecutionRejected { + input: UpdateJobExecutionSubscriptionRequest, + output: RejectedResponse +} structure UpdateJobExecutionRequest { @required @@ -326,8 +350,10 @@ document JobDocument @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/notify") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-jobexecutionschanged") -operation SubscribeToJobExecutionsChangedEvents(JobExecutionsChangedSubscriptionRequest) - -> JobExecutionsChangedSubscriptionResponse +operation SubscribeToJobExecutionsChangedEvents { + input: JobExecutionsChangedSubscriptionRequest, + output: JobExecutionsChangedSubscriptionResponse +} structure JobExecutionsChangedSubscriptionRequest { @required @@ -358,8 +384,10 @@ map JobExecutionsChangedJobs { @smithy.mqtt#subscribe("$aws/things/{thingName}/jobs/notify-next") @externalDocumentation("https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-nextjobexecutionchanged") -operation SubscribeToNextJobExecutionChangedEvents(NextJobExecutionChangedSubscriptionRequest) - -> NextJobExecutionChangedSubscriptionResponse +operation SubscribeToNextJobExecutionChangedEvents { + input: NextJobExecutionChangedSubscriptionRequest, + output: NextJobExecutionChangedSubscriptionResponse +} structure NextJobExecutionChangedSubscriptionRequest { @required diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/mqtt-operations-with-errors.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/mqtt-operations-with-errors.smithy index 0b543136926..720fa3cca6f 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/mqtt-operations-with-errors.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/mqtt-operations-with-errors.smithy @@ -3,7 +3,10 @@ namespace smithy.example @smithy.mqtt#subscribe("event1") -operation Foo() -> FooOutput errors [Error] +operation Foo { + output: FooOutput, + errors: [Error] +} structure FooOutput { @eventStream @@ -17,6 +20,9 @@ structure Error {} @smithy.mqtt#publish("event2") -operation Baz(BazInput) errors [Error] +operation Baz { + input: BazInput, + errors: [Error] +} structure BazInput {} diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/mqtt-topic-labels.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/mqtt-topic-labels.smithy index 7b4749903a8..4c3c6d790b1 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/mqtt-topic-labels.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/mqtt-topic-labels.smithy @@ -2,12 +2,14 @@ namespace smithy.example // Missing input for {foo} property. @smithy.mqtt#publish("events1/{foo}") -operation Operation1() +operation Operation1 {} // Missing {foo} member. @smithy.mqtt#publish("events2/{foo}") -operation Operation2(Operation2Input) +operation Operation2 { + input: Operation2Input +} structure Operation2Input { baz: smithy.api#String, @@ -16,7 +18,9 @@ structure Operation2Input { // Extraneous {baz} label member. @smithy.mqtt#publish("events3/{foo}") -operation Operation3(Operation3Input) +operation Operation3 { + input: Operation3Input +} structure Operation3Input { @required @@ -31,7 +35,9 @@ structure Operation3Input { // Missing topicLabel trait for {foo} @smithy.mqtt#publish("events4/{foo}") -operation Operation4(Operation4Input) +operation Operation4 { + input: Operation4Input +} structure Operation4Input { @required @@ -41,7 +47,9 @@ structure Operation4Input { // No errors. @smithy.mqtt#publish("events5/{foo}") -operation Operation5(Operation5Input) +operation Operation5 { + input: Operation5Input +} structure Operation5Input { @required diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/publish-with-eventstream.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/publish-with-eventstream.smithy index 29d71a54cf0..cf5eba6d041 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/publish-with-eventstream.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/publish-with-eventstream.smithy @@ -1,7 +1,9 @@ namespace smithy.example @smithy.mqtt#publish("foo") -operation Publish(PublishInput) +operation Publish { + input: PublishInput +} structure PublishInput { @eventStream // invalid diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-input-missing-label.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-input-missing-label.smithy index 6f018cdb0d8..ed6e677c994 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-input-missing-label.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-input-missing-label.smithy @@ -8,7 +8,10 @@ use smithy.mqtt#topicLabel use smithy.mqtt#subscribe @subscribe("events/{foo}") -operation Foo(FooInput) -> FooOutput +operation Foo { + input: FooInput, + output: FooOutput +} structure FooInput { @required diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-missing-output.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-missing-output.smithy index aff9773b7f3..629b5e8aaac 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-missing-output.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-missing-output.smithy @@ -3,4 +3,4 @@ namespace smithy.example @smithy.mqtt#subscribe("events") -operation Foo() +operation Foo {} diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-operation-initial-event.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-operation-initial-event.smithy index e8fb77943b7..d287046d8c4 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-operation-initial-event.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-operation-initial-event.smithy @@ -3,7 +3,9 @@ namespace smithy.example @smithy.mqtt#subscribe("events") -operation Foo() -> FooOutput +operation Foo { + output: FooOutput +} structure FooOutput { badMember: smithy.api#String, // <-- Erroneous initial event member diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-operation-missing-event-stream.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-operation-missing-event-stream.smithy index 74d24f46b25..0263f26196c 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-operation-missing-event-stream.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/subscribe-operation-missing-event-stream.smithy @@ -3,6 +3,8 @@ namespace smithy.example @smithy.mqtt#subscribe("events") -operation Foo() -> FooOutput +operation Foo { + output: FooOutput +} structure FooOutput {} diff --git a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/topic-conflicts.smithy b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/topic-conflicts.smithy index 28f4992e892..b3ae8973c11 100644 --- a/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/topic-conflicts.smithy +++ b/smithy-mqtt-traits/src/test/resources/software/amazon/smithy/mqtt/traits/testsuite/topic-conflicts.smithy @@ -2,17 +2,25 @@ namespace smithy.example // Conflicts with B, C @smithy.mqtt#publish("a") -operation A(AInput) +operation A { + input: AInput +} + structure AInput {} // Conflicts with A, C @smithy.mqtt#publish("a") -operation B(BInput) +operation B { + input: BInput +} + structure BInput {} // Conflicts with A, B @smithy.mqtt#subscribe("a") -operation C() -> COutput +operation C { + output: COutput +} structure COutput { @eventStream @@ -24,14 +32,20 @@ structure EmptyEvent {} // D and E do not conflict since they use the same payload. @smithy.mqtt#publish("b") -operation D(DInput) +operation D { + input: DInput +} structure DInput {} @smithy.mqtt#publish("b") -operation E(DInput) +operation E { + input: DInput +} @smithy.mqtt#subscribe("b") -operation F() -> FOutput +operation F { + output: FOutput +} structure FOutput { @eventStream diff --git a/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/greedy-labels.smithy b/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/greedy-labels.smithy index e2eb485f6bb..60e49a0e772 100644 --- a/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/greedy-labels.smithy +++ b/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/greedy-labels.smithy @@ -7,7 +7,9 @@ service Greedy { } @http(method: "GET", uri: "/{greedy+}") -operation GreedyOperation(GreedyOperationInput) +operation GreedyOperation { + input: GreedyOperationInput +} structure GreedyOperationInput { @required diff --git a/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/prefix-headers.smithy b/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/prefix-headers.smithy index e89d644e72f..d594c1bfc2f 100644 --- a/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/prefix-headers.smithy +++ b/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/prefix-headers.smithy @@ -7,7 +7,10 @@ service PrefixHeaders { } @http(method: "GET", uri: "/") -operation PrefixHeadersOperation(Input) -> Output +operation PrefixHeadersOperation { + input: Input, + output: Output +} structure Input { @httpPrefixHeaders("x-custom-") diff --git a/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/small-service.smithy b/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/small-service.smithy index 172fb3e2bee..74d74a84d85 100644 --- a/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/small-service.smithy +++ b/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/small-service.smithy @@ -7,6 +7,8 @@ service Small { } @http(method: "GET", uri: "/") -operation SmallOperation(SmallOperationInput) +operation SmallOperation { + input: SmallOperationInput +} structure SmallOperationInput {} diff --git a/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/streaming-service.smithy b/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/streaming-service.smithy index 086508904f8..700319e277f 100644 --- a/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/streaming-service.smithy +++ b/smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/mappers/streaming-service.smithy @@ -8,7 +8,9 @@ service Streaming { @http(method: "GET", uri: "/") @readonly -operation StreamingOperation() -> Output +operation StreamingOperation { + output: Output +} structure Output { @httpPayload diff --git a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/all-request-features.smithy b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/all-request-features.smithy index 77bb03df1c8..cf63e9d2ac1 100644 --- a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/all-request-features.smithy +++ b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/all-request-features.smithy @@ -26,7 +26,9 @@ use smithy.test#httpRequestTests vendorParams: {foo: "Bar"} } ]) -operation SayHello(SayHelloInput) +operation SayHello { + input: SayHelloInput +} structure SayHelloInput { @httpPayload diff --git a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/all-response-features.smithy b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/all-response-features.smithy index 794dda0587d..14efd78aade 100644 --- a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/all-response-features.smithy +++ b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/all-response-features.smithy @@ -27,7 +27,9 @@ use smithy.test#httpResponseTests documentation: "Hi" } ]) -operation GetFoo() -> GetFooOutput +operation GetFoo { + output: GetFooOutput +} structure GetFooOutput { @httpPayload diff --git a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-duplicate-ids.smithy b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-duplicate-ids.smithy index 827933bb0af..e5857fd4ace 100644 --- a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-duplicate-ids.smithy +++ b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-duplicate-ids.smithy @@ -16,7 +16,9 @@ use smithy.test#httpRequestTests code: 200, } ]) -operation SayGoodbye() -> SayGoodbyeOutput +operation SayGoodbye { + output: SayGoodbyeOutput +} structure SayGoodbyeOutput {} @httpResponseTests([ @@ -49,7 +51,9 @@ structure MyError {} uri: "/", }, ]) -operation SayHello(SayHelloInput) +operation SayHello { + input: SayHelloInput +} structure SayHelloInput {} @http(method: "POST", uri: "/") @@ -67,5 +71,8 @@ structure SayHelloInput {} uri: "/", } ]) -operation SayHello2(SayHelloInput2) +operation SayHello2 { + input: SayHelloInput2 +} + structure SayHelloInput2 {} diff --git a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-invalid-params.smithy b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-invalid-params.smithy index f4a109220f2..fb046951c30 100644 --- a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-invalid-params.smithy +++ b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/detects-invalid-params.smithy @@ -14,7 +14,10 @@ use smithy.test#httpRequestTests } } ]) -operation SayGoodbye() -> SayGoodbyeOutput +operation SayGoodbye { + output: SayGoodbyeOutput +} + structure SayGoodbyeOutput {} @httpResponseTests([ @@ -44,7 +47,10 @@ structure MyError { } } ]) -operation SayHello(SayHelloInput) +operation SayHello { + input: SayHelloInput +} + structure SayHelloInput { badType: Boolean } diff --git a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/timestamp-validation.smithy b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/timestamp-validation.smithy index 610aad3aed2..bbe832fad62 100644 --- a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/timestamp-validation.smithy +++ b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/errorfiles/timestamp-validation.smithy @@ -14,7 +14,9 @@ use smithy.test#httpRequestTests } } ]) -operation HasTime(HasTimeInput) +operation HasTime { + input: HasTimeInput +} structure HasTimeInput { time: Timestamp, diff --git a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/say-goodbye.smithy b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/say-goodbye.smithy index c15bbd3aa15..bff67448ccd 100644 --- a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/say-goodbye.smithy +++ b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/say-goodbye.smithy @@ -15,7 +15,9 @@ use smithy.test#httpResponseTests } } ]) -operation SayGoodbye() -> SayGoodbyeOutput +operation SayGoodbye { + output: SayGoodbyeOutput +} structure SayGoodbyeOutput { @httpHeader("X-Farewell") diff --git a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/say-hello.smithy b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/say-hello.smithy index be509a4cef6..6b82e3a4aff 100644 --- a/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/say-hello.smithy +++ b/smithy-protocol-test-traits/src/test/resources/software/amazon/smithy/protocoltests/traits/say-hello.smithy @@ -20,7 +20,9 @@ use smithy.test#httpRequestTests bodyMediaType: "application/json" } ]) -operation SayHello(SayHelloInput) +operation SayHello { + input: SayHelloInput +} structure SayHelloInput { @httpHeader("X-Greeting")