@@ -33,6 +33,8 @@ type SpecAnalyser struct {
3333 Definitions1 spec.Definitions
3434 Definitions2 spec.Definitions
3535 ReferencedDefinitions map [string ]bool
36+
37+ schemasCompared map [string ]struct {}
3638}
3739
3840// NewSpecAnalyser returns an empty SpecDiffs
@@ -45,6 +47,7 @@ func NewSpecAnalyser() *SpecAnalyser {
4547
4648// Analyse the differences in two specs
4749func (sd * SpecAnalyser ) Analyse (spec1 , spec2 * spec.Swagger ) error {
50+ sd .schemasCompared = make (map [string ]struct {})
4851 sd .Definitions1 = spec1 .Definitions
4952 sd .Definitions2 = spec2 .Definitions
5053 sd .urlMethods1 = getURLMethodsFor (spec1 )
@@ -425,8 +428,14 @@ func (sd *SpecAnalyser) compareSchema(location DifferenceLocation, schema1, sche
425428 }
426429
427430 if isRefType (schema1 ) {
431+ key := schemaLocationKey (location )
432+ if _ , ok := sd .schemasCompared [key ]; ok {
433+ return
434+ }
435+ sd .schemasCompared [key ] = struct {}{}
428436 schema1 , _ = sd .schemaFromRef (getRef (schema1 ), & sd .Definitions1 )
429437 }
438+
430439 if isRefType (schema2 ) {
431440 schema2 , _ = sd .schemaFromRef (getRef (schema2 ), & sd .Definitions2 )
432441 }
@@ -522,6 +531,10 @@ func (sd *SpecAnalyser) schemaFromRef(ref spec.Ref, defns *spec.Definitions) (ac
522531
523532}
524533
534+ func schemaLocationKey (location DifferenceLocation ) string {
535+ return location .Method + location .URL + location .Node .Field + location .Node .TypeName
536+ }
537+
525538// PropertyDefn combines a property with its required-ness
526539type PropertyDefn struct {
527540 Schema * spec.Schema
0 commit comments