From 812b8b6c10dd6f6d3b4be28d5d4bfcf6e4aafdd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Wed, 21 May 2025 22:38:22 -0400 Subject: [PATCH] support more edge cases including aliases and merge --- decode.go | 39 ++ decode_test.go | 107 ++++ .../proto/buf/protoyaml/test/v1/edge.pb.go | 543 ++++++++++++++++++ .../proto/buf/protoyaml/test/v1/edge.proto | 56 ++ 4 files changed, 745 insertions(+) create mode 100644 internal/gen/proto/buf/protoyaml/test/v1/edge.pb.go create mode 100644 internal/proto/buf/protoyaml/test/v1/edge.proto diff --git a/decode.go b/decode.go index 5ff6be9..0eb1035 100644 --- a/decode.go +++ b/decode.go @@ -610,6 +610,10 @@ func (u *unmarshaler) unmarshalField(node *yaml.Node, field protoreflect.FieldDe } } + if node.Kind == yaml.AliasNode { + node = node.Alias + } + switch { case field.IsList(): u.unmarshalList(node, field, message.ProtoReflect().Mutable(field).List()) @@ -626,6 +630,10 @@ func (u *unmarshaler) unmarshalField(node *yaml.Node, field protoreflect.FieldDe // Unmarshal the list, with explicit handling for lists of messages. func (u *unmarshaler) unmarshalList(node *yaml.Node, field protoreflect.FieldDescriptor, list protoreflect.List) { + // Could be an empty list + if isNull(node) { + return + } if u.checkKind(node, yaml.SequenceNode) { switch field.Kind() { case protoreflect.MessageKind, protoreflect.GroupKind: @@ -636,6 +644,9 @@ func (u *unmarshaler) unmarshalList(node *yaml.Node, field protoreflect.FieldDes } default: for _, itemNode := range node.Content { + if itemNode.Kind == yaml.AliasNode { + itemNode = itemNode.Alias + } val, ok := u.unmarshalScalar(itemNode, field, false) if !ok { continue @@ -656,6 +667,14 @@ func (u *unmarshaler) unmarshalMap(node *yaml.Node, field protoreflect.FieldDesc for i := 1; i < len(node.Content); i += 2 { keyNode := node.Content[i-1] valueNode := node.Content[i] + // Unfold any merge + if isMerge(keyNode) { + if valueNode.Kind == yaml.AliasNode { + valueNode = valueNode.Alias + } + u.unmarshalMap(valueNode, field, mapVal) + continue + } mapKey, ok := u.unmarshalScalar(keyNode, mapKeyField, true) if !ok { continue @@ -679,6 +698,10 @@ func isNull(node *yaml.Node) bool { return node.Tag == "!!null" } +func isMerge(node *yaml.Node) bool { + return node.Tag == "!!merge" +} + // Resolve the node to be used with the custom unmarshaler. Returns nil if the // there was an error. func (u *unmarshaler) findNodeForCustom(node *yaml.Node, forAny bool) *yaml.Node { @@ -729,6 +752,9 @@ func (u *unmarshaler) unmarshalMessage(node *yaml.Node, message proto.Message, f if isNull(node) { return // Null is always allowed for messages } + if node.Kind == yaml.AliasNode { + node = node.Alias + } if node.Kind != yaml.MappingNode { u.addErrorf(node, "expected fields for %v, got %v", message.ProtoReflect().Descriptor().FullName(), getNodeKind(node.Kind)) @@ -745,6 +771,15 @@ func (u *unmarshaler) unmarshalMessageFields(node *yaml.Node, message proto.Mess var key string switch keyNode.Kind { case yaml.ScalarNode: + // Unfold if it's a merge node + if isMerge(keyNode) { + valueNode := node.Content[i+1] + if valueNode.Kind == yaml.AliasNode { + valueNode = valueNode.Alias + } + u.unmarshalMessageFields(valueNode, message, forAny) + continue + } key = keyNode.Value case yaml.SequenceNode: // Interpret single element sequences as extension field. @@ -1006,6 +1041,10 @@ func (u *unmarshaler) unmarshalValue( node *yaml.Node, value *structpb.Value, ) { + // If the node is an alias, use the real node + if node.Kind == yaml.AliasNode { + node = node.Alias + } // Unmarshal the value. switch node.Kind { case yaml.SequenceNode: // A list. diff --git a/decode_test.go b/decode_test.go index 0bc5cdd..9a3159d 100644 --- a/decode_test.go +++ b/decode_test.go @@ -214,3 +214,110 @@ values: require.NoError(t, err) require.Equal(t, "hi", actual.GetValues()[0].GetOneofStringValue()) } + +func TestEmptySequence(t *testing.T) { + data := []byte(` +sequence: `) + actual := &testv1.EdgeTestSequence{} + err := Unmarshal(data, actual) + require.NoError(t, err) + require.Empty(t, actual.Sequence) +} + +func TestAliasScalar(t *testing.T) { + data := []byte(` +foo: &alias value +bar: *alias`) + actual := &testv1.EdgeTestTwoScalar{} + err := Unmarshal(data, actual) + require.NoError(t, err) + require.Equal(t, "value", actual.Foo) + require.Equal(t, "value", actual.Bar) +} + +func TestAliasSequenceItem(t *testing.T) { + data := []byte(` +foo: + - &alias item +bar: + - *alias`) + actual := &testv1.EdgeTestTwoSequence{} + err := Unmarshal(data, actual) + require.NoError(t, err) + require.Len(t, actual.Foo, 1) + require.Equal(t, "item", actual.Foo[0]) + require.Len(t, actual.Bar, 1) + require.Equal(t, "item", actual.Bar[0]) +} + +func TestAliasSequenceMessageItem(t *testing.T) { + data := []byte(` +nested: + - &alias + foo: value + bar: value +second_nested: + - *alias`) + actual := &testv1.EdgeTestNestedMessageSequence{} + err := Unmarshal(data, actual) + require.NoError(t, err) + require.Len(t, actual.Nested, 1) + require.Equal(t, "value", actual.Nested[0].Foo) + require.Equal(t, "value", actual.Nested[0].Bar) + require.Len(t, actual.SecondNested, 1) + require.Equal(t, "value", actual.SecondNested[0].Foo) + require.Equal(t, "value", actual.SecondNested[0].Bar) +} + +func TestAliasMap(t *testing.T) { + data := []byte(` +foo: &alias + key1: value + key2: value +bar: *alias +`) + actual := &testv1.EdgeTestTwoMap{} + err := Unmarshal(data, actual) + require.NoError(t, err) + require.Len(t, actual.Foo, 2) + require.Equal(t, "value", actual.Foo["key1"]) + require.Equal(t, "value", actual.Foo["key2"]) + require.Len(t, actual.Bar, 2) + require.Equal(t, "value", actual.Bar["key1"]) + require.Equal(t, "value", actual.Bar["key2"]) +} + +func TestMergeMap(t *testing.T) { + data := []byte(` +foo: &alias + key1: value + key2: value +bar: + << : *alias + key3: value + key4: value +`) + actual := &testv1.EdgeTestTwoMap{} + err := Unmarshal(data, actual) + require.NoError(t, err) + require.Len(t, actual.Foo, 2) + require.Len(t, actual.Bar, 4) +} + +func TestMergeMessage(t *testing.T) { + data := []byte(` +nested: &alias + foo: value + bar: value +second_nested: + << : *alias + bar: another value +`) + actual := &testv1.EdgeTestNestedMessage{} + err := Unmarshal(data, actual) + require.NoError(t, err) + require.Equal(t, "value", actual.Nested.Foo) + require.Equal(t, "value", actual.Nested.Bar) + require.Equal(t, "value", actual.SecondNested.Foo) + require.Equal(t, "another value", actual.SecondNested.Bar) +} diff --git a/internal/gen/proto/buf/protoyaml/test/v1/edge.pb.go b/internal/gen/proto/buf/protoyaml/test/v1/edge.pb.go new file mode 100644 index 0000000..ebcb17d --- /dev/null +++ b/internal/gen/proto/buf/protoyaml/test/v1/edge.pb.go @@ -0,0 +1,543 @@ +// Copyright 2023-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc (unknown) +// source: buf/protoyaml/test/v1/edge.proto + +package testv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type EdgeTestSequence struct { + state protoimpl.MessageState `protogen:"open.v1"` + Sequence []string `protobuf:"bytes,1,rep,name=sequence,proto3" json:"sequence,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EdgeTestSequence) Reset() { + *x = EdgeTestSequence{} + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EdgeTestSequence) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EdgeTestSequence) ProtoMessage() {} + +func (x *EdgeTestSequence) ProtoReflect() protoreflect.Message { + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EdgeTestSequence.ProtoReflect.Descriptor instead. +func (*EdgeTestSequence) Descriptor() ([]byte, []int) { + return file_buf_protoyaml_test_v1_edge_proto_rawDescGZIP(), []int{0} +} + +func (x *EdgeTestSequence) GetSequence() []string { + if x != nil { + return x.Sequence + } + return nil +} + +type EdgeTestTwoScalar struct { + state protoimpl.MessageState `protogen:"open.v1"` + Foo string `protobuf:"bytes,1,opt,name=foo,proto3" json:"foo,omitempty"` + Bar string `protobuf:"bytes,2,opt,name=bar,proto3" json:"bar,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EdgeTestTwoScalar) Reset() { + *x = EdgeTestTwoScalar{} + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EdgeTestTwoScalar) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EdgeTestTwoScalar) ProtoMessage() {} + +func (x *EdgeTestTwoScalar) ProtoReflect() protoreflect.Message { + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EdgeTestTwoScalar.ProtoReflect.Descriptor instead. +func (*EdgeTestTwoScalar) Descriptor() ([]byte, []int) { + return file_buf_protoyaml_test_v1_edge_proto_rawDescGZIP(), []int{1} +} + +func (x *EdgeTestTwoScalar) GetFoo() string { + if x != nil { + return x.Foo + } + return "" +} + +func (x *EdgeTestTwoScalar) GetBar() string { + if x != nil { + return x.Bar + } + return "" +} + +type EdgeTestTwoSequence struct { + state protoimpl.MessageState `protogen:"open.v1"` + Foo []string `protobuf:"bytes,1,rep,name=foo,proto3" json:"foo,omitempty"` + Bar []string `protobuf:"bytes,2,rep,name=bar,proto3" json:"bar,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EdgeTestTwoSequence) Reset() { + *x = EdgeTestTwoSequence{} + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EdgeTestTwoSequence) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EdgeTestTwoSequence) ProtoMessage() {} + +func (x *EdgeTestTwoSequence) ProtoReflect() protoreflect.Message { + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EdgeTestTwoSequence.ProtoReflect.Descriptor instead. +func (*EdgeTestTwoSequence) Descriptor() ([]byte, []int) { + return file_buf_protoyaml_test_v1_edge_proto_rawDescGZIP(), []int{2} +} + +func (x *EdgeTestTwoSequence) GetFoo() []string { + if x != nil { + return x.Foo + } + return nil +} + +func (x *EdgeTestTwoSequence) GetBar() []string { + if x != nil { + return x.Bar + } + return nil +} + +type EdgeTestTwoMap struct { + state protoimpl.MessageState `protogen:"open.v1"` + Foo map[string]string `protobuf:"bytes,1,rep,name=foo,proto3" json:"foo,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Bar map[string]string `protobuf:"bytes,2,rep,name=bar,proto3" json:"bar,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EdgeTestTwoMap) Reset() { + *x = EdgeTestTwoMap{} + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EdgeTestTwoMap) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EdgeTestTwoMap) ProtoMessage() {} + +func (x *EdgeTestTwoMap) ProtoReflect() protoreflect.Message { + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EdgeTestTwoMap.ProtoReflect.Descriptor instead. +func (*EdgeTestTwoMap) Descriptor() ([]byte, []int) { + return file_buf_protoyaml_test_v1_edge_proto_rawDescGZIP(), []int{3} +} + +func (x *EdgeTestTwoMap) GetFoo() map[string]string { + if x != nil { + return x.Foo + } + return nil +} + +func (x *EdgeTestTwoMap) GetBar() map[string]string { + if x != nil { + return x.Bar + } + return nil +} + +type EdgeTestNestedMessage struct { + state protoimpl.MessageState `protogen:"open.v1"` + Nested *EdgeTestNestedMessage_Nested `protobuf:"bytes,1,opt,name=nested,proto3" json:"nested,omitempty"` + SecondNested *EdgeTestNestedMessage_Nested `protobuf:"bytes,2,opt,name=second_nested,json=secondNested,proto3" json:"second_nested,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EdgeTestNestedMessage) Reset() { + *x = EdgeTestNestedMessage{} + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EdgeTestNestedMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EdgeTestNestedMessage) ProtoMessage() {} + +func (x *EdgeTestNestedMessage) ProtoReflect() protoreflect.Message { + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EdgeTestNestedMessage.ProtoReflect.Descriptor instead. +func (*EdgeTestNestedMessage) Descriptor() ([]byte, []int) { + return file_buf_protoyaml_test_v1_edge_proto_rawDescGZIP(), []int{4} +} + +func (x *EdgeTestNestedMessage) GetNested() *EdgeTestNestedMessage_Nested { + if x != nil { + return x.Nested + } + return nil +} + +func (x *EdgeTestNestedMessage) GetSecondNested() *EdgeTestNestedMessage_Nested { + if x != nil { + return x.SecondNested + } + return nil +} + +type EdgeTestNestedMessageSequence struct { + state protoimpl.MessageState `protogen:"open.v1"` + Nested []*EdgeTestNestedMessageSequence_Nested `protobuf:"bytes,1,rep,name=nested,proto3" json:"nested,omitempty"` + SecondNested []*EdgeTestNestedMessageSequence_Nested `protobuf:"bytes,2,rep,name=second_nested,json=secondNested,proto3" json:"second_nested,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EdgeTestNestedMessageSequence) Reset() { + *x = EdgeTestNestedMessageSequence{} + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EdgeTestNestedMessageSequence) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EdgeTestNestedMessageSequence) ProtoMessage() {} + +func (x *EdgeTestNestedMessageSequence) ProtoReflect() protoreflect.Message { + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EdgeTestNestedMessageSequence.ProtoReflect.Descriptor instead. +func (*EdgeTestNestedMessageSequence) Descriptor() ([]byte, []int) { + return file_buf_protoyaml_test_v1_edge_proto_rawDescGZIP(), []int{5} +} + +func (x *EdgeTestNestedMessageSequence) GetNested() []*EdgeTestNestedMessageSequence_Nested { + if x != nil { + return x.Nested + } + return nil +} + +func (x *EdgeTestNestedMessageSequence) GetSecondNested() []*EdgeTestNestedMessageSequence_Nested { + if x != nil { + return x.SecondNested + } + return nil +} + +type EdgeTestNestedMessage_Nested struct { + state protoimpl.MessageState `protogen:"open.v1"` + Foo string `protobuf:"bytes,1,opt,name=foo,proto3" json:"foo,omitempty"` + Bar string `protobuf:"bytes,2,opt,name=bar,proto3" json:"bar,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EdgeTestNestedMessage_Nested) Reset() { + *x = EdgeTestNestedMessage_Nested{} + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EdgeTestNestedMessage_Nested) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EdgeTestNestedMessage_Nested) ProtoMessage() {} + +func (x *EdgeTestNestedMessage_Nested) ProtoReflect() protoreflect.Message { + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EdgeTestNestedMessage_Nested.ProtoReflect.Descriptor instead. +func (*EdgeTestNestedMessage_Nested) Descriptor() ([]byte, []int) { + return file_buf_protoyaml_test_v1_edge_proto_rawDescGZIP(), []int{4, 0} +} + +func (x *EdgeTestNestedMessage_Nested) GetFoo() string { + if x != nil { + return x.Foo + } + return "" +} + +func (x *EdgeTestNestedMessage_Nested) GetBar() string { + if x != nil { + return x.Bar + } + return "" +} + +type EdgeTestNestedMessageSequence_Nested struct { + state protoimpl.MessageState `protogen:"open.v1"` + Foo string `protobuf:"bytes,1,opt,name=foo,proto3" json:"foo,omitempty"` + Bar string `protobuf:"bytes,2,opt,name=bar,proto3" json:"bar,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EdgeTestNestedMessageSequence_Nested) Reset() { + *x = EdgeTestNestedMessageSequence_Nested{} + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EdgeTestNestedMessageSequence_Nested) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EdgeTestNestedMessageSequence_Nested) ProtoMessage() {} + +func (x *EdgeTestNestedMessageSequence_Nested) ProtoReflect() protoreflect.Message { + mi := &file_buf_protoyaml_test_v1_edge_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EdgeTestNestedMessageSequence_Nested.ProtoReflect.Descriptor instead. +func (*EdgeTestNestedMessageSequence_Nested) Descriptor() ([]byte, []int) { + return file_buf_protoyaml_test_v1_edge_proto_rawDescGZIP(), []int{5, 0} +} + +func (x *EdgeTestNestedMessageSequence_Nested) GetFoo() string { + if x != nil { + return x.Foo + } + return "" +} + +func (x *EdgeTestNestedMessageSequence_Nested) GetBar() string { + if x != nil { + return x.Bar + } + return "" +} + +var File_buf_protoyaml_test_v1_edge_proto protoreflect.FileDescriptor + +const file_buf_protoyaml_test_v1_edge_proto_rawDesc = "" + + "\n" + + " buf/protoyaml/test/v1/edge.proto\x12\x15buf.protoyaml.test.v1\".\n" + + "\x10EdgeTestSequence\x12\x1a\n" + + "\bsequence\x18\x01 \x03(\tR\bsequence\"7\n" + + "\x11EdgeTestTwoScalar\x12\x10\n" + + "\x03foo\x18\x01 \x01(\tR\x03foo\x12\x10\n" + + "\x03bar\x18\x02 \x01(\tR\x03bar\"9\n" + + "\x13EdgeTestTwoSequence\x12\x10\n" + + "\x03foo\x18\x01 \x03(\tR\x03foo\x12\x10\n" + + "\x03bar\x18\x02 \x03(\tR\x03bar\"\x84\x02\n" + + "\x0eEdgeTestTwoMap\x12@\n" + + "\x03foo\x18\x01 \x03(\v2..buf.protoyaml.test.v1.EdgeTestTwoMap.FooEntryR\x03foo\x12@\n" + + "\x03bar\x18\x02 \x03(\v2..buf.protoyaml.test.v1.EdgeTestTwoMap.BarEntryR\x03bar\x1a6\n" + + "\bFooEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\x1a6\n" + + "\bBarEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xec\x01\n" + + "\x15EdgeTestNestedMessage\x12K\n" + + "\x06nested\x18\x01 \x01(\v23.buf.protoyaml.test.v1.EdgeTestNestedMessage.NestedR\x06nested\x12X\n" + + "\rsecond_nested\x18\x02 \x01(\v23.buf.protoyaml.test.v1.EdgeTestNestedMessage.NestedR\fsecondNested\x1a,\n" + + "\x06Nested\x12\x10\n" + + "\x03foo\x18\x01 \x01(\tR\x03foo\x12\x10\n" + + "\x03bar\x18\x02 \x01(\tR\x03bar\"\x84\x02\n" + + "\x1dEdgeTestNestedMessageSequence\x12S\n" + + "\x06nested\x18\x01 \x03(\v2;.buf.protoyaml.test.v1.EdgeTestNestedMessageSequence.NestedR\x06nested\x12`\n" + + "\rsecond_nested\x18\x02 \x03(\v2;.buf.protoyaml.test.v1.EdgeTestNestedMessageSequence.NestedR\fsecondNested\x1a,\n" + + "\x06Nested\x12\x10\n" + + "\x03foo\x18\x01 \x01(\tR\x03foo\x12\x10\n" + + "\x03bar\x18\x02 \x01(\tR\x03barB\xe5\x01\n" + + "\x19com.buf.protoyaml.test.v1B\tEdgeProtoP\x01ZFbuf.build/go/protoyaml/internal/gen/proto/buf/protoyaml/test/v1;testv1\xa2\x02\x03BPT\xaa\x02\x15Buf.Protoyaml.Test.V1\xca\x02\x15Buf\\Protoyaml\\Test\\V1\xe2\x02!Buf\\Protoyaml\\Test\\V1\\GPBMetadata\xea\x02\x18Buf::Protoyaml::Test::V1b\x06proto3" + +var ( + file_buf_protoyaml_test_v1_edge_proto_rawDescOnce sync.Once + file_buf_protoyaml_test_v1_edge_proto_rawDescData []byte +) + +func file_buf_protoyaml_test_v1_edge_proto_rawDescGZIP() []byte { + file_buf_protoyaml_test_v1_edge_proto_rawDescOnce.Do(func() { + file_buf_protoyaml_test_v1_edge_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_buf_protoyaml_test_v1_edge_proto_rawDesc), len(file_buf_protoyaml_test_v1_edge_proto_rawDesc))) + }) + return file_buf_protoyaml_test_v1_edge_proto_rawDescData +} + +var file_buf_protoyaml_test_v1_edge_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_buf_protoyaml_test_v1_edge_proto_goTypes = []any{ + (*EdgeTestSequence)(nil), // 0: buf.protoyaml.test.v1.EdgeTestSequence + (*EdgeTestTwoScalar)(nil), // 1: buf.protoyaml.test.v1.EdgeTestTwoScalar + (*EdgeTestTwoSequence)(nil), // 2: buf.protoyaml.test.v1.EdgeTestTwoSequence + (*EdgeTestTwoMap)(nil), // 3: buf.protoyaml.test.v1.EdgeTestTwoMap + (*EdgeTestNestedMessage)(nil), // 4: buf.protoyaml.test.v1.EdgeTestNestedMessage + (*EdgeTestNestedMessageSequence)(nil), // 5: buf.protoyaml.test.v1.EdgeTestNestedMessageSequence + nil, // 6: buf.protoyaml.test.v1.EdgeTestTwoMap.FooEntry + nil, // 7: buf.protoyaml.test.v1.EdgeTestTwoMap.BarEntry + (*EdgeTestNestedMessage_Nested)(nil), // 8: buf.protoyaml.test.v1.EdgeTestNestedMessage.Nested + (*EdgeTestNestedMessageSequence_Nested)(nil), // 9: buf.protoyaml.test.v1.EdgeTestNestedMessageSequence.Nested +} +var file_buf_protoyaml_test_v1_edge_proto_depIdxs = []int32{ + 6, // 0: buf.protoyaml.test.v1.EdgeTestTwoMap.foo:type_name -> buf.protoyaml.test.v1.EdgeTestTwoMap.FooEntry + 7, // 1: buf.protoyaml.test.v1.EdgeTestTwoMap.bar:type_name -> buf.protoyaml.test.v1.EdgeTestTwoMap.BarEntry + 8, // 2: buf.protoyaml.test.v1.EdgeTestNestedMessage.nested:type_name -> buf.protoyaml.test.v1.EdgeTestNestedMessage.Nested + 8, // 3: buf.protoyaml.test.v1.EdgeTestNestedMessage.second_nested:type_name -> buf.protoyaml.test.v1.EdgeTestNestedMessage.Nested + 9, // 4: buf.protoyaml.test.v1.EdgeTestNestedMessageSequence.nested:type_name -> buf.protoyaml.test.v1.EdgeTestNestedMessageSequence.Nested + 9, // 5: buf.protoyaml.test.v1.EdgeTestNestedMessageSequence.second_nested:type_name -> buf.protoyaml.test.v1.EdgeTestNestedMessageSequence.Nested + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_buf_protoyaml_test_v1_edge_proto_init() } +func file_buf_protoyaml_test_v1_edge_proto_init() { + if File_buf_protoyaml_test_v1_edge_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_buf_protoyaml_test_v1_edge_proto_rawDesc), len(file_buf_protoyaml_test_v1_edge_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_buf_protoyaml_test_v1_edge_proto_goTypes, + DependencyIndexes: file_buf_protoyaml_test_v1_edge_proto_depIdxs, + MessageInfos: file_buf_protoyaml_test_v1_edge_proto_msgTypes, + }.Build() + File_buf_protoyaml_test_v1_edge_proto = out.File + file_buf_protoyaml_test_v1_edge_proto_goTypes = nil + file_buf_protoyaml_test_v1_edge_proto_depIdxs = nil +} diff --git a/internal/proto/buf/protoyaml/test/v1/edge.proto b/internal/proto/buf/protoyaml/test/v1/edge.proto new file mode 100644 index 0000000..19acb19 --- /dev/null +++ b/internal/proto/buf/protoyaml/test/v1/edge.proto @@ -0,0 +1,56 @@ +// Copyright 2023-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buf.protoyaml.test.v1; + +message EdgeTestSequence { + repeated string sequence = 1; +} + +message EdgeTestTwoScalar { + string foo = 1; + string bar = 2; +} + +message EdgeTestTwoSequence { + repeated string foo = 1; + repeated string bar = 2; +} + +message EdgeTestTwoMap { + map foo = 1; + map bar = 2; +} + +message EdgeTestNestedMessage { + message Nested { + string foo = 1; + string bar = 2; + } + + Nested nested = 1; + Nested second_nested = 2; +} + +message EdgeTestNestedMessageSequence { + message Nested { + string foo = 1; + string bar = 2; + } + + repeated Nested nested = 1; + repeated Nested second_nested = 2; +} \ No newline at end of file