mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
chore: update to use iterators on orderedmaps
This commit is contained in:
committed by
quobix
parent
c3eb16d4e4
commit
161a41f73b
@@ -5,8 +5,9 @@ package v3
|
||||
|
||||
import (
|
||||
"github.com/pb33f/libopenapi/datamodel/high"
|
||||
"github.com/pb33f/libopenapi/datamodel/low"
|
||||
lowmodel "github.com/pb33f/libopenapi/datamodel/low"
|
||||
low "github.com/pb33f/libopenapi/datamodel/low/v3"
|
||||
lowv3 "github.com/pb33f/libopenapi/datamodel/low/v3"
|
||||
"github.com/pb33f/libopenapi/orderedmap"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
@@ -19,11 +20,11 @@ type Encoding struct {
|
||||
Style string `json:"style,omitempty" yaml:"style,omitempty"`
|
||||
Explode *bool `json:"explode,omitempty" yaml:"explode,omitempty"`
|
||||
AllowReserved bool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
|
||||
low *low.Encoding
|
||||
low *lowv3.Encoding
|
||||
}
|
||||
|
||||
// NewEncoding creates a new instance of Encoding from a low-level one.
|
||||
func NewEncoding(encoding *low.Encoding) *Encoding {
|
||||
func NewEncoding(encoding *lowv3.Encoding) *Encoding {
|
||||
e := new(Encoding)
|
||||
e.low = encoding
|
||||
e.ContentType = encoding.ContentType.Value
|
||||
@@ -37,7 +38,7 @@ func NewEncoding(encoding *low.Encoding) *Encoding {
|
||||
}
|
||||
|
||||
// GoLow returns the low-level Encoding instance used to create the high-level one.
|
||||
func (e *Encoding) GoLow() *low.Encoding {
|
||||
func (e *Encoding) GoLow() *lowv3.Encoding {
|
||||
return e.low
|
||||
}
|
||||
|
||||
@@ -58,10 +59,6 @@ func (e *Encoding) MarshalYAML() (interface{}, error) {
|
||||
}
|
||||
|
||||
// ExtractEncoding converts hard to navigate low-level plumbing Encoding definitions, into a high-level simple map
|
||||
func ExtractEncoding(elements *orderedmap.Map[lowmodel.KeyReference[string], lowmodel.ValueReference[*low.Encoding]]) *orderedmap.Map[string, *Encoding] {
|
||||
extracted := orderedmap.New[string, *Encoding]()
|
||||
for pair := orderedmap.First(elements); pair != nil; pair = pair.Next() {
|
||||
extracted.Set(pair.Key().Value, NewEncoding(pair.Value().Value))
|
||||
}
|
||||
return extracted
|
||||
func ExtractEncoding(elements *orderedmap.Map[lowmodel.KeyReference[string], lowmodel.ValueReference[*lowv3.Encoding]]) *orderedmap.Map[string, *Encoding] {
|
||||
return low.FromReferenceMapWithFunc(elements, NewEncoding)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user