diff --git a/internal/otelschema/group.go b/internal/otelschema/group.go index d00237d8..e62df8d2 100644 --- a/internal/otelschema/group.go +++ b/internal/otelschema/group.go @@ -21,7 +21,7 @@ type Attribute struct { Brief OptString `json:"brief"` Note OptString `json:"note"` Tag OptString `json:"tag"` - Examples jx.Raw `json:"examples"` + Examples []jx.Raw `json:"examples"` RequirementLevel OptRequirementLevel `json:"requirement_level"` Stability OptString `json:"stability"` } @@ -57,7 +57,7 @@ func (s *Attribute) GetTag() OptString { } // GetExamples returns the value of Examples. -func (s *Attribute) GetExamples() jx.Raw { +func (s *Attribute) GetExamples() []jx.Raw { return s.Examples } @@ -102,7 +102,7 @@ func (s *Attribute) SetTag(val OptString) { } // SetExamples sets the value of Examples. -func (s *Attribute) SetExamples(val jx.Raw) { +func (s *Attribute) SetExamples(val []jx.Raw) { s.Examples = val } @@ -862,9 +862,15 @@ func (s *Attribute) encodeFields(e *jx.Encoder) { } } { - if len(s.Examples) != 0 { + if s.Examples != nil { e.FieldStart("examples") - e.Raw(s.Examples) + e.ArrStart() + for _, elem := range s.Examples { + if len(elem) != 0 { + e.Raw(elem) + } + } + e.ArrEnd() } } { @@ -966,9 +972,17 @@ func (s *Attribute) Decode(d *jx.Decoder) error { } case "examples": if err := func() error { - v, err := d.RawAppend(nil) - s.Examples = jx.Raw(v) - if err != nil { + s.Examples = make([]jx.Raw, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem jx.Raw + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + s.Examples = append(s.Examples, elem) + return nil + }); err != nil { return err } return nil diff --git a/internal/otelschema/schema.yml b/internal/otelschema/schema.yml index 3c5c217f..e67998ae 100644 --- a/internal/otelschema/schema.yml +++ b/internal/otelschema/schema.yml @@ -73,7 +73,9 @@ $defs: type: string tag: type: string - examples: {} + examples: + type: array + items: {} requirement_level: $ref: "#/$defs/requirementLevel" stability: