-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for IDLv2 nullability semantics #1767
Comments
I believe this is being tracked in another issue, and it is certainly on the roadmap to match v2 semantics in their entirety before a 1.0 release. |
Yeah, there is a SDK issue for it: awslabs/aws-sdk-rust#536 I'm going to leave this open to track implementation in smithy-rs. |
I think we need to make some code generator changes to I wrote a quick test in @Test
fun `IDLv2 client @required fields are not options`() {
val model = """
namespace com.test
structure MyStruct {
@required
foo: String,
@required
baz: Integer,
}
""".asSmithyModel(smithyVersion = "2.0")
val struct = model.lookup<StructureShape>("com.test#MyStruct")
val provider = testSymbolProvider(model)
val project = TestWorkspace.testProject(provider)
project.useShapeWriter(inner) { writer ->
writer.withModule("model") {
StructureGenerator(model, provider, writer, struct).render()
}
writer.rustBlock("fn check_optionality(s: &MyStruct)") {
rust(
"""
let _: &String = &s.foo;
let _: &i32 = &s.baz;
""",
)
}
}
project.compileAndTest()
}
Edit: Actually, everything is wired up correctly, and I managed to get it to code generate without |
We're still waiting on some internal developments before we can begin work on this issue. |
This appears to be assigned to Zelda now. Is this now scheduled for work on the smithy side? Really looking forward to this update, thank you! |
I'm aiming to get to it in Q2, but who can know what the future holds? |
Regarding the interaction of Structure member optionality says in the
Not all structures used as operation inputs are marked as operation MyOperation {
input: SharedStruct
}
structure SharedStruct {
@required
member: String
} So a smithy-rs user with the above model would hope that this would get synthesized as: struct SharedStruct {
member: String
} However, we unconditionally apply the operation MyOperation {
input: MyOperationInput
}
@input
structure MyOperationInput {
@required
member: String
} Hence the cell in that table says we should render this as: struct MyOperationInput {
member: Option<String>
} And that will upset smithy-rs users, because from their perspective they rightfully think that they should get a non |
## Motivation and Context To implement #1767 we need to support error-correction to default values when instantiating builders. - https://smithy.io/2.0/spec/aggregate-types.html?highlight=error%20correction#client-error-correction ## Description Adds `pub(crate) correct_errors_<shape>` method that will be used in deserialization to set default values for required fields when not set in the serialized response. This only applies to client via `ClientBuilderInstantiator` ## Testing - added a new test that's fairly exhaustive ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
In order to be able to take full advantage of the new nullability semantics in IDLv2 the clients needs to have a mechanism to keep track whether or not a member with a default value has been updated, quoting from the Defaults and Model Evolution document
The text was updated successfully, but these errors were encountered: