-
Notifications
You must be signed in to change notification settings - Fork 10
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
[Bug]: ProtobufferCoding doesn't add explicit presence information to optional message properties. #424
Comments
This will also apply to Input types: e.g. having the Handler defined as follows: struct AddReviewHandler: Handler {
@Parameter(.http(.body))
var review: ReviewForm
@Parameter
var eventID: Event.ID
@Parameter
var userID: User.ID
@Parameter
var displayName = false
func handle() throws -> ReviewForm {
try .instance(or: notFound)
}
} This will yield the following proto file output. service SomeService {
rpc AddReviewHandler(.QONECTIQ2.AddReviewHandlerInput) returns (.QONECTIQ2.ReviewForm);
}
message AddReviewHandlerInput {
.QONECTIQ2.ReviewForm review = 1;
string eventID = 2;
string userID = 3;
bool displayName = 4;
} |
1: Had a look at the missing 2: IMO in the case of input types the current behaviour (not making the field optional) is the correct one. ProtobufferCoding doesn't really know that the property has a default value (the property's type within Swift's type system is still struct CustomInputType: Codable, Content {
var name: String = "Lukas"
}
struct MyHandler: Handler {
@Parameter var input: CustomInputType
...
} The problem here is that there is no way to access the default value of a property at runtime (at least not that I'm aware of), so ProtobufferCoding would never even know that the property has a default value and could therefore be made optional.
|
I'm also only talking about handling The semantic für
I don't think this is an inconsistency. On the one side we have a |
Description
To my testing, with the current state of
ApdoiniGRPC
/ProtobufferCoding
, theoptional
label isn't added to message files where the Swift type is declared with an optional scalar value for the respective field (e.g. the message typeFoo
has a property likevar bar: String
).Reproduction
Expected behavior
I would expect something like the following to be generated:
I know there was a time, with initial versions of proto3 where this wasn't supported. But afaik this syntax is supported with current versions of proto3 syntax (e.g. refer to https://stackoverflow.com/a/62566052/15337360).
Additional context
CC @lukas
Code of Conduct
The text was updated successfully, but these errors were encountered: