fix: continued moving everything to orderedmaps plus cleaned up most the tests

This commit is contained in:
Tristan Cartledge
2023-12-01 17:37:07 +00:00
parent 0f3d0cb28f
commit a4ad09aab3
169 changed files with 3435 additions and 3764 deletions

View File

@@ -46,7 +46,6 @@ type ComponentsChanges struct {
// CompareComponents will compare OpenAPI components for any changes. Accepts Swagger Definition objects
// like ParameterDefinitions or Definitions etc.
func CompareComponents(l, r any) *ComponentsChanges {
var changes []*Change
cc := new(ComponentsChanges)
@@ -56,7 +55,7 @@ func CompareComponents(l, r any) *ComponentsChanges {
reflect.TypeOf(&v2.ParameterDefinitions{}) == reflect.TypeOf(r) {
lDef := l.(*v2.ParameterDefinitions)
rDef := r.(*v2.ParameterDefinitions)
var a, b orderedmap.Map[low.KeyReference[string], low.ValueReference[*v2.Parameter]]
var a, b *orderedmap.Map[low.KeyReference[string], low.ValueReference[*v2.Parameter]]
if lDef != nil {
a = lDef.Definitions
}
@@ -71,7 +70,7 @@ func CompareComponents(l, r any) *ComponentsChanges {
reflect.TypeOf(&v2.ResponsesDefinitions{}) == reflect.TypeOf(r) {
lDef := l.(*v2.ResponsesDefinitions)
rDef := r.(*v2.ResponsesDefinitions)
var a, b orderedmap.Map[low.KeyReference[string], low.ValueReference[*v2.Response]]
var a, b *orderedmap.Map[low.KeyReference[string], low.ValueReference[*v2.Response]]
if lDef != nil {
a = lDef.Definitions
}
@@ -86,7 +85,7 @@ func CompareComponents(l, r any) *ComponentsChanges {
reflect.TypeOf(&v2.Definitions{}) == reflect.TypeOf(r) {
lDef := l.(*v2.Definitions)
rDef := r.(*v2.Definitions)
var a, b orderedmap.Map[low.KeyReference[string], low.ValueReference[*base.SchemaProxy]]
var a, b *orderedmap.Map[low.KeyReference[string], low.ValueReference[*base.SchemaProxy]]
if lDef != nil {
a = lDef.Schemas
}
@@ -101,7 +100,7 @@ func CompareComponents(l, r any) *ComponentsChanges {
reflect.TypeOf(&v2.SecurityDefinitions{}) == reflect.TypeOf(r) {
lDef := l.(*v2.SecurityDefinitions)
rDef := r.(*v2.SecurityDefinitions)
var a, b orderedmap.Map[low.KeyReference[string], low.ValueReference[*v2.SecurityScheme]]
var a, b *orderedmap.Map[low.KeyReference[string], low.ValueReference[*v2.SecurityScheme]]
if lDef != nil {
a = lDef.Definitions
}
@@ -218,9 +217,9 @@ type componentComparison struct {
}
// run a generic comparison in a thread which in turn splits checks into further threads.
func runComparison[T any, R any](l, r orderedmap.Map[low.KeyReference[string], low.ValueReference[T]],
changes *[]*Change, label string, compareFunc func(l, r T) R, doneChan chan componentComparison) {
func runComparison[T any, R any](l, r *orderedmap.Map[low.KeyReference[string], low.ValueReference[T]],
changes *[]*Change, label string, compareFunc func(l, r T) R, doneChan chan componentComparison,
) {
// for schemas
if label == v3.SchemasLabel || label == v2.DefinitionsLabel || label == v3.SecuritySchemesLabel {
doneChan <- componentComparison{