mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 12:37:48 +00:00
Refactored version directory names
3.0 and 2.0 do not work, there are multiple versions and anything with a period in it sucks from my point of view, v2 and v3 feel much better from a DX perspective.
This commit is contained in:
43
datamodel/low/v3/encoding.go
Normal file
43
datamodel/low/v3/encoding.go
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v3
|
||||
|
||||
import (
|
||||
"github.com/pb33f/libopenapi/datamodel/low"
|
||||
"github.com/pb33f/libopenapi/index"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const (
|
||||
EncodingLabel = "encoding"
|
||||
)
|
||||
|
||||
type Encoding struct {
|
||||
ContentType low.NodeReference[string]
|
||||
Headers low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Header]]
|
||||
Style low.NodeReference[string]
|
||||
Explode low.NodeReference[bool]
|
||||
AllowReserved low.NodeReference[bool]
|
||||
}
|
||||
|
||||
func (en *Encoding) FindHeader(hType string) *low.ValueReference[*Header] {
|
||||
return low.FindItemInMap[*Header](hType, en.Headers.Value)
|
||||
}
|
||||
|
||||
func (en *Encoding) Build(root *yaml.Node, idx *index.SpecIndex) error {
|
||||
|
||||
headers, hL, hN, err := low.ExtractMapFlat[*Header](HeadersLabel, root, idx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if headers != nil {
|
||||
en.Headers = low.NodeReference[map[low.KeyReference[string]]low.ValueReference[*Header]]{
|
||||
Value: headers,
|
||||
KeyNode: hL,
|
||||
ValueNode: hN,
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user