mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
Cleaned up model interfaces for parameters
overlapping getters created a mess, the mess is now clean.
This commit is contained in:
@@ -5,15 +5,24 @@ package low
|
|||||||
|
|
||||||
type SharedParameters interface {
|
type SharedParameters interface {
|
||||||
Hash() [32]byte
|
Hash() [32]byte
|
||||||
GetType() *NodeReference[string]
|
GetName() *NodeReference[string]
|
||||||
|
GetIn() *NodeReference[string]
|
||||||
GetDescription() *NodeReference[string]
|
GetDescription() *NodeReference[string]
|
||||||
GetDeprecated() *NodeReference[bool]
|
GetAllowEmptyValue() *NodeReference[bool]
|
||||||
|
GetRequired() *NodeReference[bool]
|
||||||
|
GetSchema() *NodeReference[any] // requires cast.
|
||||||
|
}
|
||||||
|
|
||||||
|
type HasDescription interface {
|
||||||
|
GetDescription() *NodeReference[string]
|
||||||
|
}
|
||||||
|
|
||||||
|
type SwaggerParameter interface {
|
||||||
|
SharedParameters
|
||||||
|
GetType() *NodeReference[string]
|
||||||
GetFormat() *NodeReference[string]
|
GetFormat() *NodeReference[string]
|
||||||
GetStyle() *NodeReference[string]
|
|
||||||
GetCollectionFormat() *NodeReference[string]
|
GetCollectionFormat() *NodeReference[string]
|
||||||
GetDefault() *NodeReference[any]
|
GetDefault() *NodeReference[any]
|
||||||
GetAllowReserved() *NodeReference[bool]
|
|
||||||
GetExplode() *NodeReference[bool]
|
|
||||||
GetMaximum() *NodeReference[int]
|
GetMaximum() *NodeReference[int]
|
||||||
GetExclusiveMaximum() *NodeReference[bool]
|
GetExclusiveMaximum() *NodeReference[bool]
|
||||||
GetMinimum() *NodeReference[int]
|
GetMinimum() *NodeReference[int]
|
||||||
@@ -26,27 +35,6 @@ type SharedParameters interface {
|
|||||||
GetUniqueItems() *NodeReference[bool]
|
GetUniqueItems() *NodeReference[bool]
|
||||||
GetEnum() *NodeReference[[]ValueReference[string]]
|
GetEnum() *NodeReference[[]ValueReference[string]]
|
||||||
GetMultipleOf() *NodeReference[int]
|
GetMultipleOf() *NodeReference[int]
|
||||||
GetExample() *NodeReference[any]
|
|
||||||
GetSchema() *NodeReference[any] // requires cast.
|
|
||||||
GetExamples() *NodeReference[any] // requires cast
|
|
||||||
GetContent() *NodeReference[any] // requires cast.
|
|
||||||
GetItems() *NodeReference[any] // requires cast.
|
|
||||||
}
|
|
||||||
|
|
||||||
type IsParameter interface {
|
|
||||||
GetName() *NodeReference[string]
|
|
||||||
GetIn() *NodeReference[string]
|
|
||||||
SharedParameterHeader
|
|
||||||
SharedParameters
|
|
||||||
}
|
|
||||||
|
|
||||||
type SharedParameterHeader interface {
|
|
||||||
GetRequired() *NodeReference[bool]
|
|
||||||
GetAllowEmptyValue() *NodeReference[bool]
|
|
||||||
}
|
|
||||||
|
|
||||||
type HasDescription interface {
|
|
||||||
GetDescription() *NodeReference[string]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SwaggerHeader interface {
|
type SwaggerHeader interface {
|
||||||
@@ -82,7 +70,18 @@ type OpenAPIHeader interface {
|
|||||||
GetRequired() *NodeReference[bool]
|
GetRequired() *NodeReference[bool]
|
||||||
GetAllowEmptyValue() *NodeReference[bool]
|
GetAllowEmptyValue() *NodeReference[bool]
|
||||||
GetSchema() *NodeReference[any] // requires cast.
|
GetSchema() *NodeReference[any] // requires cast.
|
||||||
GetExamples() *NodeReference[any] // requires cast
|
GetExamples() *NodeReference[any] // requires cast.
|
||||||
|
GetContent() *NodeReference[any] // requires cast.
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpenAPIParameter interface {
|
||||||
|
SharedParameters
|
||||||
|
GetDeprecated() *NodeReference[bool]
|
||||||
|
GetStyle() *NodeReference[string]
|
||||||
|
GetAllowReserved() *NodeReference[bool]
|
||||||
|
GetExplode() *NodeReference[bool]
|
||||||
|
GetExample() *NodeReference[any]
|
||||||
|
GetExamples() *NodeReference[any] // requires cast.
|
||||||
GetContent() *NodeReference[any] // requires cast.
|
GetContent() *NodeReference[any] // requires cast.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,10 +91,10 @@ type SharedOperations interface {
|
|||||||
GetDescription() NodeReference[string]
|
GetDescription() NodeReference[string]
|
||||||
GetDeprecated() NodeReference[bool]
|
GetDeprecated() NodeReference[bool]
|
||||||
GetExtensions() map[KeyReference[string]]ValueReference[any]
|
GetExtensions() map[KeyReference[string]]ValueReference[any]
|
||||||
GetExternalDocs() NodeReference[any] // requires cast
|
GetExternalDocs() NodeReference[any] // requires cast.
|
||||||
GetResponses() NodeReference[any] // requires cast
|
GetResponses() NodeReference[any] // requires cast.
|
||||||
GetParameters() NodeReference[any] // requires cast
|
GetParameters() NodeReference[any] // requires cast.
|
||||||
GetSecurity() NodeReference[any] // requires cast
|
GetSecurity() NodeReference[any] // requires cast.
|
||||||
}
|
}
|
||||||
|
|
||||||
type SwaggerOperations interface {
|
type SwaggerOperations interface {
|
||||||
@@ -108,5 +107,5 @@ type SwaggerOperations interface {
|
|||||||
type OpenAPIOperations interface {
|
type OpenAPIOperations interface {
|
||||||
SharedOperations
|
SharedOperations
|
||||||
//GetCallbacks() NodeReference[map[KeyReference[string]]ValueReference[any]] // requires cast
|
//GetCallbacks() NodeReference[map[KeyReference[string]]ValueReference[any]] // requires cast
|
||||||
GetServers() NodeReference[any] // requires cast
|
GetServers() NodeReference[any] // requires cast.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,6 +150,9 @@ func (i *Items) GetItems() *low.NodeReference[any] {
|
|||||||
func (i *Items) GetCollectionFormat() *low.NodeReference[string] {
|
func (i *Items) GetCollectionFormat() *low.NodeReference[string] {
|
||||||
return &i.CollectionFormat
|
return &i.CollectionFormat
|
||||||
}
|
}
|
||||||
|
func (i *Items) GetDescription() *low.NodeReference[string] {
|
||||||
|
return nil // not implemented, but required to align with header contract
|
||||||
|
}
|
||||||
func (i *Items) GetDefault() *low.NodeReference[any] {
|
func (i *Items) GetDefault() *low.NodeReference[any] {
|
||||||
return &i.Default
|
return &i.Default
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func addPropertyCheck(props *[]*PropertyCheck,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func addOpenAPIParameterProperties(left, right low.IsParameter, changes *[]*Change) []*PropertyCheck {
|
func addOpenAPIParameterProperties(left, right low.OpenAPIParameter, changes *[]*Change) []*PropertyCheck {
|
||||||
var props []*PropertyCheck
|
var props []*PropertyCheck
|
||||||
|
|
||||||
// style
|
// style
|
||||||
@@ -100,7 +100,7 @@ func addOpenAPIParameterProperties(left, right low.IsParameter, changes *[]*Chan
|
|||||||
return props
|
return props
|
||||||
}
|
}
|
||||||
|
|
||||||
func addSwaggerParameterProperties(left, right low.IsParameter, changes *[]*Change) []*PropertyCheck {
|
func addSwaggerParameterProperties(left, right low.SwaggerParameter, changes *[]*Change) []*PropertyCheck {
|
||||||
var props []*PropertyCheck
|
var props []*PropertyCheck
|
||||||
|
|
||||||
// type
|
// type
|
||||||
@@ -166,7 +166,7 @@ func addSwaggerParameterProperties(left, right low.IsParameter, changes *[]*Chan
|
|||||||
return props
|
return props
|
||||||
}
|
}
|
||||||
|
|
||||||
func addCommonParameterProperties(left, right low.IsParameter, changes *[]*Change) []*PropertyCheck {
|
func addCommonParameterProperties(left, right low.SharedParameters, changes *[]*Change) []*PropertyCheck {
|
||||||
var props []*PropertyCheck
|
var props []*PropertyCheck
|
||||||
|
|
||||||
addPropertyCheck(&props, left.GetName().ValueNode, right.GetName().ValueNode,
|
addPropertyCheck(&props, left.GetName().ValueNode, right.GetName().ValueNode,
|
||||||
|
|||||||
@@ -324,18 +324,18 @@ func compareSwaggerPathItem(lPath, rPath *v2.PathItem, changes *[]*Change, pc *P
|
|||||||
return props
|
return props
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractV2ParametersIntoInterface(l, r []low.ValueReference[*v2.Parameter]) ([]low.ValueReference[low.IsParameter],
|
func extractV2ParametersIntoInterface(l, r []low.ValueReference[*v2.Parameter]) ([]low.ValueReference[low.SharedParameters],
|
||||||
[]low.ValueReference[low.IsParameter]) {
|
[]low.ValueReference[low.SharedParameters]) {
|
||||||
lp := make([]low.ValueReference[low.IsParameter], len(l))
|
lp := make([]low.ValueReference[low.SharedParameters], len(l))
|
||||||
rp := make([]low.ValueReference[low.IsParameter], len(r))
|
rp := make([]low.ValueReference[low.SharedParameters], len(r))
|
||||||
for i := range l {
|
for i := range l {
|
||||||
lp[i] = low.ValueReference[low.IsParameter]{
|
lp[i] = low.ValueReference[low.SharedParameters]{
|
||||||
Value: l[i].Value,
|
Value: l[i].Value,
|
||||||
ValueNode: l[i].ValueNode,
|
ValueNode: l[i].ValueNode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i := range r {
|
for i := range r {
|
||||||
rp[i] = low.ValueReference[low.IsParameter]{
|
rp[i] = low.ValueReference[low.SharedParameters]{
|
||||||
Value: r[i].Value,
|
Value: r[i].Value,
|
||||||
ValueNode: r[i].ValueNode,
|
ValueNode: r[i].ValueNode,
|
||||||
}
|
}
|
||||||
@@ -343,18 +343,18 @@ func extractV2ParametersIntoInterface(l, r []low.ValueReference[*v2.Parameter])
|
|||||||
return lp, rp
|
return lp, rp
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractV3ParametersIntoInterface(l, r []low.ValueReference[*v3.Parameter]) ([]low.ValueReference[low.IsParameter],
|
func extractV3ParametersIntoInterface(l, r []low.ValueReference[*v3.Parameter]) ([]low.ValueReference[low.SharedParameters],
|
||||||
[]low.ValueReference[low.IsParameter]) {
|
[]low.ValueReference[low.SharedParameters]) {
|
||||||
lp := make([]low.ValueReference[low.IsParameter], len(l))
|
lp := make([]low.ValueReference[low.SharedParameters], len(l))
|
||||||
rp := make([]low.ValueReference[low.IsParameter], len(r))
|
rp := make([]low.ValueReference[low.SharedParameters], len(r))
|
||||||
for i := range l {
|
for i := range l {
|
||||||
lp[i] = low.ValueReference[low.IsParameter]{
|
lp[i] = low.ValueReference[low.SharedParameters]{
|
||||||
Value: l[i].Value,
|
Value: l[i].Value,
|
||||||
ValueNode: l[i].ValueNode,
|
ValueNode: l[i].ValueNode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i := range r {
|
for i := range r {
|
||||||
rp[i] = low.ValueReference[low.IsParameter]{
|
rp[i] = low.ValueReference[low.SharedParameters]{
|
||||||
Value: r[i].Value,
|
Value: r[i].Value,
|
||||||
ValueNode: r[i].ValueNode,
|
ValueNode: r[i].ValueNode,
|
||||||
}
|
}
|
||||||
@@ -362,10 +362,10 @@ func extractV3ParametersIntoInterface(l, r []low.ValueReference[*v3.Parameter])
|
|||||||
return lp, rp
|
return lp, rp
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkParameters(lParams, rParams []low.ValueReference[low.IsParameter], changes *[]*Change, pc *PathItemChanges) {
|
func checkParameters(lParams, rParams []low.ValueReference[low.SharedParameters], changes *[]*Change, pc *PathItemChanges) {
|
||||||
|
|
||||||
lv := make(map[string]low.IsParameter, len(lParams))
|
lv := make(map[string]low.SharedParameters, len(lParams))
|
||||||
rv := make(map[string]low.IsParameter, len(rParams))
|
rv := make(map[string]low.SharedParameters, len(rParams))
|
||||||
|
|
||||||
for i := range lParams {
|
for i := range lParams {
|
||||||
s := lParams[i].Value.GetName().Value
|
s := lParams[i].Value.GetName().Value
|
||||||
|
|||||||
Reference in New Issue
Block a user