render empty oauth scopes

see https://github.com/pb33f/libopenapi/issues/289
This commit is contained in:
Kellen Hart
2024-05-08 23:56:58 -07:00
committed by quobix
parent 3d92fc0b1a
commit a4a9370db8
3 changed files with 5 additions and 2 deletions

View File

@@ -429,7 +429,7 @@ func (n *NodeBuilder) AddYAMLNode(parent *yaml.Node, entry *nodes.NodeEntry) *ya
}
p := m.ToYamlNode(n, l)
if len(p.Content) > 0 {
if p.Content != nil {
valueNode = p
}
} else if r, ok := value.(Renderable); ok {

View File

@@ -16,7 +16,7 @@ type OAuthFlow struct {
AuthorizationUrl string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"`
TokenUrl string `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"`
RefreshUrl string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"`
Scopes *orderedmap.Map[string, string] `json:"scopes,omitempty" yaml:"scopes,omitempty"`
Scopes *orderedmap.Map[string, string] `json:"scopes,renderZero" yaml:"scopes,renderZero"`
Extensions *orderedmap.Map[string, *yaml.Node] `json:"-" yaml:"-"`
low *low.OAuthFlow
}

View File

@@ -36,6 +36,9 @@ type findValueUntyped interface {
// ToYamlNode converts the ordered map to a yaml node ready for marshalling.
func (o *Map[K, V]) ToYamlNode(n NodeBuilder, l any) *yaml.Node {
p := utils.CreateEmptyMapNode()
if o != nil {
p.Content = make([]*yaml.Node, 0)
}
var vn *yaml.Node