mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 04:20:17 +00:00
Building out highlevel model
bit by bit, step by step.
This commit is contained in:
@@ -3,7 +3,11 @@
|
||||
|
||||
package v3
|
||||
|
||||
import low "github.com/pb33f/libopenapi/datamodel/low/3.0"
|
||||
import (
|
||||
"github.com/pb33f/libopenapi/datamodel/high"
|
||||
lowmodel "github.com/pb33f/libopenapi/datamodel/low"
|
||||
low "github.com/pb33f/libopenapi/datamodel/low/3.0"
|
||||
)
|
||||
|
||||
type Example struct {
|
||||
Summary string
|
||||
@@ -14,6 +18,25 @@ type Example struct {
|
||||
low *low.Example
|
||||
}
|
||||
|
||||
func NewExample(example *low.Example) *Example {
|
||||
e := new(Example)
|
||||
e.low = example
|
||||
e.Summary = example.Summary.Value
|
||||
e.Description = example.Description.Value
|
||||
e.Value = example.Value
|
||||
e.ExternalValue = example.ExternalValue.Value
|
||||
e.Extensions = high.ExtractExtensions(example.Extensions)
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *Example) GoLow() *low.Example {
|
||||
return e.low
|
||||
}
|
||||
|
||||
func ExtractExamples(elements map[lowmodel.KeyReference[string]]lowmodel.ValueReference[*low.Example]) map[string]*Example {
|
||||
extracted := make(map[string]*Example)
|
||||
for k, v := range elements {
|
||||
extracted[k.Value] = NewExample(v.Value)
|
||||
}
|
||||
return extracted
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user