mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +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.
55 lines
1.4 KiB
Go
55 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"
|
|
"github.com/pb33f/libopenapi/datamodel/high/base"
|
|
low "github.com/pb33f/libopenapi/datamodel/low/v3"
|
|
)
|
|
|
|
type Parameter struct {
|
|
Name string
|
|
In string
|
|
Description string
|
|
Required bool
|
|
Deprecated bool
|
|
AllowEmptyValue bool
|
|
Style string
|
|
Explode bool
|
|
AllowReserved bool
|
|
Schema *base.SchemaProxy
|
|
Example any
|
|
Examples map[string]*base.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 = base.NewSchemaProxy(¶m.Schema)
|
|
}
|
|
p.Required = param.Required.Value
|
|
p.Example = param.Example.Value
|
|
p.Examples = base.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
|
|
}
|