mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
Working on building out models
a recursive approach? or a dfs approach? not sure yet. still playing with ideas.
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user