feat(proto): create custom option for attribute subtype
This commit is contained in:
1 parent
6a37bd9710
commit
e76db2cd13
3 files changed
+41
-13
No files matched your search
@@ -42,6 +42,11 @@ func parsePBs() {
|
||||
in.generatedStructure.name = string(desc.Name())
|
||||
for i := 0; i < desc.Fields().Len(); i++ {
|
||||
fd := desc.Fields().Get(i)
|
||||
opts := fd.Options().(*descriptorpb.FieldOptions)
|
||||
if subtype := proto.GetExtension(opts, protooptions.E_Subtype).(string); subtype != "" && subtype != "default" {
|
||||
// Skip rendering any fields except the default subtype field.
|
||||
continue
|
||||
}
|
||||
if strutil.StrListContains(in.fieldFilter, string(fd.Name())) {
|
||||
continue
|
||||
}
|
||||
@@ -55,7 +60,6 @@ func parsePBs() {
|
||||
sliceText = "[]"
|
||||
}
|
||||
// Add generate option info
|
||||
opts := fd.Options().(*descriptorpb.FieldOptions)
|
||||
if proto.GetExtension(opts, protooptions.E_GenerateSdkOption).(bool) {
|
||||
fi.GenerateSdkOption = true
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@ extend google.protobuf.FieldOptions {
|
||||
// generate_sdk_option is a directive used when generating the SDK to
|
||||
// indicate that an option should be created for the field
|
||||
bool generate_sdk_option = 85412;
|
||||
|
||||
// subtype is used for oneOf attribute subtypes, to identify that we only need to parse attributes
|
||||
// of oneOf once and not for each option when generating the API
|
||||
// This will serve as a JSON key, used to transform that into the key the protobuf expects
|
||||
string subtype = 85555;
|
||||
}
|
||||
|
||||
message MaskMapping {
|
||||
|
||||
Reference in new issue
Block a user