Can I have an option inside of an option?

21 views
Skip to first unread message

ittai zeidman

unread,
Feb 23, 2020, 10:00:05 AM2/23/20
to Protocol Buffers
Hi,
I'm trying to write a proto file which has an option on a service and inside the option I'd like to have an option on one of the inner messages:

service SomeService {
    option (wix.api.genService) = {
            entity: "SomeServiceData"
            endpoints {
                create {
                    option(wix.api.metadata).name = "SOME_VALUE";
                };
            };
    };
}
This fails saying: "Message type "wix.api.GenEndpoint" has no field named "option"." (create is of type GenEndpoint).

I'm fairly certain I can change the inner option to be a regular field but then my developers will need to know two different syntax (one when they're using the highlevel transpiled DSL and the regular proto one for other tasks).
I can also change the top level "thing" to not be an option and instead be a typed message but this feels a bit iffy (maybe less than the above two options).

This test below seems to suggest what I want to do is achievable but I wasn't able to understand how to use it...

Would love your help,
Ittai

ittai zeidman

unread,
Feb 23, 2020, 10:32:14 AM2/23/20
to Protocol Buffers
After playing with it a bit I think I can't actually change the top level "thing" to not be an option since an option is the (only?) way for a developer to give values for a pre-defined data structure.

I guess I'm down to dropping the inner options and duplicating the data structures unless some hero will save my day :) 
Reply all
Reply to author
Forward
0 new messages