mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
Schemas are now rendered on demand. There is no reasonable way to navigate the mayhem that is circular dependencies through multiple inheritance and polymorphism. So now using a msuch simpler design (and MUCH faster), there is a `SchemaProxy` for every schema reference. This holds a reference to the low model and index, that renders the schema on demand. Once rendered, it's done. Any children can also be rendered on demand, and so down the rabbit hole you do (if you want). All circular dependencies are know by the index, so you can decide when you want to stop, or just keep going for ever, however it's now a choice, not something decided for you. Signed-off-by: Dave Shanley <dave@quobix.com>
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v3
|
|
|
|
import (
|
|
"github.com/pb33f/libopenapi/datamodel/high"
|
|
low "github.com/pb33f/libopenapi/datamodel/low/3.0"
|
|
)
|
|
|
|
type Parameter struct {
|
|
Name string
|
|
In string
|
|
Description string
|
|
Required bool
|
|
Deprecated bool
|
|
AllowEmptyValue bool
|
|
Style string
|
|
Explode bool
|
|
AllowReserved bool
|
|
Schema *SchemaProxy
|
|
Example any
|
|
Examples map[string]*Example
|
|
Content map[string]*MediaType
|
|
Extensions map[string]any
|
|
low *low.Parameter
|
|
}
|
|
|
|
func NewParameter(param *low.Parameter) *Parameter {
|
|
p := new(Parameter)
|
|
p.low = param
|
|
p.Name = param.Name.Value
|
|
p.In = param.In.Value
|
|
p.Description = param.Description.Value
|
|
p.Deprecated = param.Deprecated.Value
|
|
p.AllowEmptyValue = param.AllowEmptyValue.Value
|
|
p.Style = param.Style.Value
|
|
p.Explode = param.Explode.Value
|
|
p.AllowReserved = param.AllowReserved.Value
|
|
if !param.Schema.IsEmpty() {
|
|
p.Schema = &SchemaProxy{schema: ¶m.Schema}
|
|
}
|
|
p.Required = param.Required.Value
|
|
p.Example = param.Example.Value
|
|
p.Examples = ExtractExamples(param.Examples.Value)
|
|
p.Content = ExtractContent(param.Content.Value)
|
|
p.Extensions = high.ExtractExtensions(param.Extensions)
|
|
return p
|
|
}
|
|
|
|
func (p *Parameter) GoLow() *low.Parameter {
|
|
return p.low
|
|
}
|