mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-07 12:37:48 +00:00
Updated readme with new docs link
Added in some new helper methods for building out new models. More details in the docs. Added another example.
This commit is contained in:
@@ -474,15 +474,16 @@ func (n *NodeBuilder) AddYAMLNode(parent *yaml.Node, entry *NodeEntry) *yaml.Nod
|
||||
case reflect.Ptr:
|
||||
if r, ok := value.(Renderable); ok {
|
||||
if gl, lg := value.(GoesLowUntyped); lg {
|
||||
|
||||
ut := reflect.ValueOf(gl.GoLowUntyped())
|
||||
if !ut.IsNil() {
|
||||
if gl.GoLowUntyped().(low.IsReferenced).IsReference() {
|
||||
rvn := utils.CreateEmptyMapNode()
|
||||
rvn.Content = append(rvn.Content, utils.CreateStringNode("$ref"))
|
||||
rvn.Content = append(rvn.Content, utils.CreateStringNode(gl.GoLowUntyped().(low.IsReferenced).GetReference()))
|
||||
valueNode = rvn
|
||||
break
|
||||
if gl.GoLowUntyped() != nil {
|
||||
ut := reflect.ValueOf(gl.GoLowUntyped())
|
||||
if !ut.IsNil() {
|
||||
if gl.GoLowUntyped().(low.IsReferenced).IsReference() {
|
||||
rvn := utils.CreateEmptyMapNode()
|
||||
rvn.Content = append(rvn.Content, utils.CreateStringNode("$ref"))
|
||||
rvn.Content = append(rvn.Content, utils.CreateStringNode(gl.GoLowUntyped().(low.IsReferenced).GetReference()))
|
||||
valueNode = rvn
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -600,6 +601,7 @@ func (n *NodeBuilder) extractLowMapKeys(fg reflect.Value, x string, found bool,
|
||||
return found, orderedCollection
|
||||
}
|
||||
|
||||
// Renderable is an interface that can be implemented by types that provide a custom MarshaYAML method.
|
||||
type Renderable interface {
|
||||
MarshalYAML() (interface{}, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user