You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is somewhat common for smithy-rs server users to want to generate an SDK from an existing Smithy model and get:
[SEVERE] Operation com.amazon.service#Operation takes in input that is
constrained
(https://awslabs.github.io/smithy/2.0/spec/constraint-traits.html), and as
such can fail with a validation exception. You must model this behavior in
the operation shape in your model file.
```smithy
use smithy.framework#ValidationException
operation Operation {
...
errors: [..., ValidationException] // <-- Add this.
}
To fix this and still have the framework honor validation, they'll have to create a new model, import the existing one, and re-define all the constrained operations' errors.
This can be a bit boilerplatey, and inconvenient when you don't own the model, so perhaps we should vend a transform that adds a given shape to an operation's list of errors.
The text was updated successfully, but these errors were encountered:
…#3803)
The Server SDK requires the model to include
`aws.smithy.framework#ValidationException` in each operation that can
access a constrained member shape. This becomes problematic when
generating the server SDK for a model not owned by the team creating the
SDK, as they cannot easily modify the model.
This PR introduces a codegen flag,
`addValidationExceptionToConstrainedOperations`. When set in
`smithy-build-template.json`, this flag will automatically add
`ValidationException` to operations that require it but do not already
list it among their errors.
Closes Issue:
[3802](#3802)
Sample `smithy-build-template.json`
```
"plugins": {
"rust-server-codegen": {
"service": "ServiceToGenerateSDKFor",
"module": "amzn-sample-server-sdk",
"codegen": {
"addValidationExceptionToConstrainedOperations": true,
}
}
}
```
---------
Co-authored-by: Fahad Zubair <[email protected]>
It is somewhat common for smithy-rs server users to want to generate an SDK from an existing Smithy model and get:
To fix this and still have the framework honor validation, they'll have to create a new model, import the existing one, and re-define all the constrained operations' errors.
This can be a bit boilerplatey, and inconvenient when you don't own the model, so perhaps we should vend a transform that adds a given shape to an operation's list of errors.
The text was updated successfully, but these errors were encountered: