mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 12:37:48 +00:00
3.0 and 2.0 do not work, there are multiple versions and anything with a period in it sucks from my point of view, v2 and v3 feel much better from a DX perspective.
34 lines
886 B
Go
34 lines
886 B
Go
// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v2
|
|
|
|
import (
|
|
highbase "github.com/pb33f/libopenapi/datamodel/high/base"
|
|
lowmodel "github.com/pb33f/libopenapi/datamodel/low"
|
|
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
|
|
low "github.com/pb33f/libopenapi/datamodel/low/v2"
|
|
)
|
|
|
|
type Definitions struct {
|
|
Definitions map[string]*highbase.SchemaProxy
|
|
low *low.Definitions
|
|
}
|
|
|
|
func NewDefinitions(definitions *low.Definitions) *Definitions {
|
|
rd := new(Definitions)
|
|
rd.low = definitions
|
|
defs := make(map[string]*highbase.SchemaProxy)
|
|
for k := range definitions.Schemas {
|
|
defs[k.Value] = highbase.NewSchemaProxy(&lowmodel.NodeReference[*lowbase.SchemaProxy]{
|
|
Value: definitions.Schemas[k].Value,
|
|
})
|
|
}
|
|
rd.Definitions = defs
|
|
return rd
|
|
}
|
|
|
|
func (d *Definitions) GoLow() *low.Definitions {
|
|
return d.low
|
|
}
|