Skip to content

Commit

Permalink
fix: comparison after schema reference change
Browse files Browse the repository at this point in the history
Continue comparison of referenced schemas after a ref change so that we
can still lint all modifications after renaming a model instead of only
returning a breaking change for this rename.
  • Loading branch information
NextFire committed Jul 10, 2024
1 parent 962f5b0 commit 9b6a374
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ public void CompareOAS_ShouldReturn_ReferenceRedirectionDifferences()
{
var differences = CompareSpecifications("reference_redirection");

differences.AssertContainsOnly(new ExpectedDifference
differences.AssertContains(new ExpectedDifference
{
Rule = ComparisonRules.ReferenceRedirection,
Severity = Severity.Warning,
OldJsonRef = "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items"
});
}, 2);
}

[Test]
Expand Down
7 changes: 3 additions & 4 deletions src/Criteo.OpenApi.Comparator/Comparators/SchemaComparator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Criteo Technology. All rights reserved.
// Copyright (c) Criteo Technology. All rights reserved.
// Licensed under the Apache 2.0 License. See LICENSE in the project root for license information.

using System.Collections.Generic;
Expand Down Expand Up @@ -45,7 +45,6 @@ internal void Compare(ComparisonContext context,
&& !newSchema.Reference.ReferenceV3.Equals(oldSchema.Reference?.ReferenceV3))
{
context.LogBreakingChange(ComparisonRules.ReferenceRedirection);
return;
}

var areSchemasReferenced = false;
Expand Down Expand Up @@ -110,10 +109,10 @@ internal void Compare(ComparisonContext context,
CompareProperties(context, oldSchema, newSchema, isSchemaReferenced);

CompareRequired(context, oldSchema.Required, newSchema.Required);

CompareNullable(context, oldSchema.Nullable, newSchema.Nullable);
}

private static void CompareNullable(ComparisonContext context,
bool oldNullable,
bool newNullable)
Expand Down

0 comments on commit 9b6a374

Please sign in to comment.