Working on building out models

a recursive approach? or a dfs approach? not sure yet. still playing with ideas.
This commit is contained in:
Dave Shanley
2022-07-29 09:44:37 -04:00
parent a906d46227
commit eda834f79f
9 changed files with 210 additions and 3 deletions

View File

@@ -1,6 +1,11 @@
package v3
import "github.com/pb33f/libopenapi/datamodel/low"
import (
"fmt"
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
"reflect"
)
type Document struct {
Version string
@@ -13,3 +18,31 @@ type Document struct {
ExternalDocs ExternalDoc
Extensions map[string]low.ObjectReference
}
func (d Document) Build(node *yaml.Node) {
doc := Document{
Version: "",
Info: Info{},
Servers: nil,
Paths: Paths{},
Components: Components{},
Security: nil,
Tags: nil,
ExternalDocs: ExternalDoc{},
Extensions: nil,
}
var j interface{}
j = doc
t := reflect.TypeOf(j)
v := reflect.ValueOf(j)
k := t.Kind()
fmt.Println("Type ", t)
fmt.Println("Value ", v)
fmt.Println("Kind ", k)
for i := 0; i < v.NumField(); i++ {
fmt.Printf("Field:%d type:%T value:%v\n", i, v.Field(i), v.Field(i))
}
}

View File

@@ -6,6 +6,10 @@ type HasNode interface {
GetNode() *yaml.Node
}
type Buildable interface {
Build(node *yaml.Node)
}
type NodeReference[T comparable] struct {
Value T
Node *yaml.Node