Files
libopenapi/datamodel/high/v2/definitions.go
Dave Shanley 3d5ecf0efb Refactored version directory names
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.
2022-09-16 08:33:39 -04:00

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
}