-
Notifications
You must be signed in to change notification settings - Fork 218
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
Structure member optionality of shapes reachable via operation outputs in IDL v2 in servers #1479
Comments
Does this need two separate issues? Seems like a very minor change to what was asked in #1478 |
While the illustrating example is identical, I opened this issue because I was surprised about the asymmetry in the provisions for optionality in server SDKs. For example, one would intuitively think that there should be an But I think the asymmetry is warranted, since those provisions are there to preserve backwards-compatibility in clients, something that an authoritative model consumer does not need to worry about. So, to answer my own questions:
Not in the case where the service owner is using a builder;
This is already contemplated in the spec. For a server SDK,
The server SDK can do this in the builder regardless of whether the member is optional or not. We gain nothing by rendering as So I'm happy with that table for server SDKs; feel free to close the issue if you agree with my reasoning. |
Looks right to me! |
The spec says that a server (i.e. an authoritative model consumer) should render a structure member shape with
@default
as(unconditionally). My reading of that is that the
bar
member of theFoo
structure in this model:should be rendered in Rust as not optional, i.e. a plain
std::string::String
:But I don't understand the purpose of
@default
then in this particular example. The service owner still has to always provide a value forbar
when returning a response; the default value"hello"
is never used.In the same way the spec makes provisions for client structure members when talking about operation inputs, shouldn't those provisions be symmetric for servers? So, in particular, these make sense for server SDKs:
@input
shape with@default
should be rendered as present (T
): the server SDK will fill in the member using the default value if it receives a request that does not set it.@output
shape with@default
should be rendered as optional (Option<T>
): the server SDK will fill in the member using the default value prior to sending a response if the service owner did not set it.The text was updated successfully, but these errors were encountered: