@@ -13,26 +13,26 @@ public class OpenApiSecuritySchemeComparer : OpenApiComparerBase<OpenApiSecurity
1313 /// <summary>
1414 /// Executes comparision against source and target <see cref="OpenApiSecurityScheme"/>.
1515 /// </summary>
16- /// <param name="sourcecSecurityScheme ">The source.</param>
16+ /// <param name="sourceSecurityScheme ">The source.</param>
1717 /// <param name="targetSecurityScheme">The target.</param>
1818 /// <param name="comparisonContext">Context under which to compare the source and target.</param>
1919 public override void Compare (
20- OpenApiSecurityScheme sourcecSecurityScheme ,
20+ OpenApiSecurityScheme sourceSecurityScheme ,
2121 OpenApiSecurityScheme targetSecurityScheme ,
2222 ComparisonContext comparisonContext )
2323 {
24- if ( sourcecSecurityScheme == null && targetSecurityScheme == null )
24+ if ( sourceSecurityScheme == null && targetSecurityScheme == null )
2525 {
2626 return ;
2727 }
2828
29- if ( sourcecSecurityScheme == null || targetSecurityScheme == null )
29+ if ( sourceSecurityScheme == null || targetSecurityScheme == null )
3030 {
3131 comparisonContext . AddOpenApiDifference (
3232 new OpenApiDifference
3333 {
3434 OpenApiDifferenceOperation = OpenApiDifferenceOperation . Update ,
35- SourceValue = sourcecSecurityScheme ,
35+ SourceValue = sourceSecurityScheme ,
3636 TargetValue = targetSecurityScheme ,
3737 OpenApiComparedElementType = typeof ( OpenApiSecurityScheme ) ,
3838 Pointer = comparisonContext . PathString
@@ -41,40 +41,66 @@ public override void Compare(
4141 return ;
4242 }
4343
44- new OpenApiReferenceComparer < OpenApiSecurityScheme > ( )
45- . Compare ( sourcecSecurityScheme . Reference , targetSecurityScheme . Reference ,
46- comparisonContext ) ;
44+ if ( sourceSecurityScheme . Reference != null
45+ && targetSecurityScheme . Reference != null
46+ && sourceSecurityScheme . Reference . Id != targetSecurityScheme . Reference . Id )
47+ {
48+ WalkAndAddOpenApiDifference (
49+ comparisonContext ,
50+ OpenApiConstants . DollarRef ,
51+ new OpenApiDifference
52+ {
53+ OpenApiDifferenceOperation = OpenApiDifferenceOperation . Update ,
54+ SourceValue = sourceSecurityScheme . Reference ,
55+ TargetValue = targetSecurityScheme . Reference ,
56+ OpenApiComparedElementType = typeof ( OpenApiReference )
57+ } ) ;
58+
59+ return ;
60+ }
61+
62+ if ( sourceSecurityScheme . Reference != null )
63+ {
64+ sourceSecurityScheme = ( OpenApiSecurityScheme ) comparisonContext . SourceDocument . ResolveReference (
65+ sourceSecurityScheme . Reference ) ;
66+ }
67+
68+ if ( targetSecurityScheme . Reference != null )
69+ {
70+ targetSecurityScheme = ( OpenApiSecurityScheme ) comparisonContext . TargetDocument . ResolveReference (
71+ targetSecurityScheme . Reference ) ;
72+ }
4773
4874 WalkAndCompare ( comparisonContext , OpenApiConstants . Description ,
49- ( ) => Compare ( sourcecSecurityScheme . Description , targetSecurityScheme . Description , comparisonContext ) ) ;
75+ ( ) => Compare ( sourceSecurityScheme . Description , targetSecurityScheme . Description , comparisonContext ) ) ;
5076
5177 WalkAndCompare ( comparisonContext , OpenApiConstants . Type ,
52- ( ) => Compare < SecuritySchemeType > ( sourcecSecurityScheme . Type , targetSecurityScheme . Type ,
78+ ( ) => Compare < SecuritySchemeType > ( sourceSecurityScheme . Type , targetSecurityScheme . Type ,
5379 comparisonContext ) ) ;
5480
5581 WalkAndCompare ( comparisonContext , OpenApiConstants . Name ,
56- ( ) => Compare ( sourcecSecurityScheme . Name , targetSecurityScheme . Name , comparisonContext ) ) ;
82+ ( ) => Compare ( sourceSecurityScheme . Name , targetSecurityScheme . Name , comparisonContext ) ) ;
5783
5884 WalkAndCompare ( comparisonContext , OpenApiConstants . In ,
59- ( ) => Compare < ParameterLocation > ( sourcecSecurityScheme . In , targetSecurityScheme . In , comparisonContext ) ) ;
85+ ( ) => Compare < ParameterLocation > ( sourceSecurityScheme . In , targetSecurityScheme . In , comparisonContext ) ) ;
6086
6187 WalkAndCompare ( comparisonContext , OpenApiConstants . Scheme ,
62- ( ) => Compare ( sourcecSecurityScheme . Scheme , targetSecurityScheme . Scheme , comparisonContext ) ) ;
88+ ( ) => Compare ( sourceSecurityScheme . Scheme , targetSecurityScheme . Scheme , comparisonContext ) ) ;
6389
6490 WalkAndCompare ( comparisonContext , OpenApiConstants . BearerFormat ,
65- ( ) => Compare ( sourcecSecurityScheme . BearerFormat , targetSecurityScheme . BearerFormat ,
91+ ( ) => Compare ( sourceSecurityScheme . BearerFormat , targetSecurityScheme . BearerFormat ,
6692 comparisonContext ) ) ;
6793
6894 WalkAndCompare ( comparisonContext , OpenApiConstants . OpenIdConnectUrl ,
69- ( ) => Compare ( sourcecSecurityScheme . OpenIdConnectUrl , targetSecurityScheme . OpenIdConnectUrl ,
95+ ( ) => Compare ( sourceSecurityScheme . OpenIdConnectUrl , targetSecurityScheme . OpenIdConnectUrl ,
7096 comparisonContext ) ) ;
7197
7298 WalkAndCompare (
7399 comparisonContext ,
74100 OpenApiConstants . Flows ,
75101 ( ) => comparisonContext
76102 . GetComparer < OpenApiOAuthFlows > ( )
77- . Compare ( sourcecSecurityScheme . Flows , targetSecurityScheme . Flows , comparisonContext ) ) ;
103+ . Compare ( sourceSecurityScheme . Flows , targetSecurityScheme . Flows , comparisonContext ) ) ;
78104 }
79105 }
80106}
0 commit comments