Hi team,
Sorry for a bit weird title and it is probably just very stupid question, please bear with me.
Based on https://smithy.io/2.0/spec/type-refinement-traits.html#input-trait:
Required members of a structure marked with the @input trait are implicitly considered clientOptional
clientOptional on the other hand:
Requires that non-authoritative generators like clients treat a structure member as optional regardless of if the member is also marked with the required trait or default trait.
So if I have the following model:
operation GetItem {
input := {
@required
itemId: String
}
}
Based on the documentation above, itemId shouldn't be considered to be required from the client side, but it should be treated as such from the server side.
I understand that intention is to prevent breaking changes, but if later I decide to add another input:
operation GetItem {
input := {
@required
itemId: String
@required
category: String
}
}
And if I run smithy diff tool for this model against the one above - it won't report any breaking changes because category: String is implicitly marked as clientOptional, but if you make a call without this field from the client side - it will result in a request rejection because the server requires this field (it doesn't have a default value nor it is optional). To me it feels like implicitly adding clientOptional to all required fields hides the backward compatibility issue that could have been detected with diff tool, but it wasn't because of clientOptional.
I understand that if you re-use types between inputs and outputs, then having clientOptional on required fields makes sense - a field always returned/generated by the server can be optional for the client to provide (or even ignored by the server if provided). But @input explicitly disallows using the type it is attached to as an output or in other operations.
So I'm a bit confused why @input should imply clientOptional and what potential problems it prevents (if you can give some examples that would be awesome).
Thank you!
Hi team,
Sorry for a bit weird title and it is probably just very stupid question, please bear with me.
Based on https://smithy.io/2.0/spec/type-refinement-traits.html#input-trait:
clientOptionalon the other hand:So if I have the following model:
Based on the documentation above,
itemIdshouldn't be considered to berequiredfrom the client side, but it should be treated as such from the server side.I understand that intention is to prevent breaking changes, but if later I decide to add another input:
And if I run smithy diff tool for this model against the one above - it won't report any breaking changes because
category: Stringis implicitly marked asclientOptional, but if you make a call without this field from the client side - it will result in a request rejection because the server requires this field (it doesn't have a default value nor it is optional). To me it feels like implicitly addingclientOptionalto all required fields hides the backward compatibility issue that could have been detected with diff tool, but it wasn't because ofclientOptional.I understand that if you re-use types between inputs and outputs, then having
clientOptionalonrequiredfields makes sense - a field always returned/generated by the server can be optional for the client to provide (or even ignored by the server if provided). But@inputexplicitly disallows using the type it is attached to as an output or in other operations.So I'm a bit confused why
@inputshould implyclientOptionaland what potential problems it prevents (if you can give some examples that would be awesome).Thank you!