typespec
typespec copied to clipboard
respect optional fields in protobuf emitter
Respect optional in protobuf emitter
The current implementation doesn't consider optionality of fields
model Test {
@field(1)
test?: boolean;
}
resulted in
message Test {
bool test = 1;
}
This PR fixes this, so the output is as expected:
message Test {
optional bool test = 1;
}
@microsoft-github-policy-service agree
Just had a call with our backend team, and this turns out to be more complex.
The optional keyword behaviour is not always the same and depend from the client language as well.
So this can be solved only with decorators because there's no constant connection between the open api optional filed definition and protobuf optional keyword presence.
Closing it for now and will try to find the time to make it through decorators.