mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
fix: continued moving everything to orderedmaps plus cleaned up most the tests
This commit is contained in:
@@ -14,11 +14,11 @@ import (
|
||||
// Encoding represents an OpenAPI 3+ Encoding object
|
||||
// - https://spec.openapis.org/oas/v3.1.0#encoding-object
|
||||
type Encoding struct {
|
||||
ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"`
|
||||
Headers orderedmap.Map[string, *Header] `json:"headers,omitempty" yaml:"headers,omitempty"`
|
||||
Style string `json:"style,omitempty" yaml:"style,omitempty"`
|
||||
Explode *bool `json:"explode,omitempty" yaml:"explode,omitempty"`
|
||||
AllowReserved bool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
|
||||
ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"`
|
||||
Headers *orderedmap.Map[string, *Header] `json:"headers,omitempty" yaml:"headers,omitempty"`
|
||||
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
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ func NewEncoding(encoding *low.Encoding) *Encoding {
|
||||
e.low = encoding
|
||||
e.ContentType = encoding.ContentType.Value
|
||||
e.Style = encoding.Style.Value
|
||||
e.Explode = &encoding.Explode.Value
|
||||
if !encoding.Explode.IsEmpty() {
|
||||
e.Explode = &encoding.Explode.Value
|
||||
}
|
||||
e.AllowReserved = encoding.AllowReserved.Value
|
||||
e.Headers = ExtractHeaders(encoding.Headers.Value)
|
||||
return e
|
||||
@@ -56,7 +58,7 @@ 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] {
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user