Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions openapi-diff/src/modeler/AutoRest.Swagger/Model/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class Schema : SwaggerObject

private LinkedList<Schema> _visitedSchemas = new LinkedList<Schema>();

/// <inheritdoc />
/// <summary>
/// Compare a modified document node (this) to a previous one and look for breaking as well as non-breaking changes.
/// </summary>
Expand All @@ -74,9 +75,7 @@ public class Schema : SwaggerObject
/// <returns>A list of messages from the comparison.</returns>
public override IEnumerable<ComparisonMessage> Compare(ComparisonContext context, SwaggerBase previous)
{
var priorSchema = previous as Schema;

if (priorSchema == null)
if (!(previous is Schema priorSchema))
{
throw new ArgumentNullException("priorVersion");
}
Expand Down Expand Up @@ -178,7 +177,7 @@ public override IEnumerable<ComparisonMessage> Compare(ComparisonContext context
/// <param name="priorSchema">Schema of the old model</param>
private void CompareRequired(ComparisonContext context, Schema priorSchema)
{
if (Required == null && priorSchema.Required == null)
if (Required == null)
{
return;
}
Expand Down Expand Up @@ -232,8 +231,7 @@ private void CompareProperties(ComparisonContext context, Schema priorSchema)
{
foreach (var def in priorSchema.Properties)
{
Schema model = null;
if (Properties == null || !Properties.TryGetValue(def.Key, out model))
if (Properties == null || !Properties.TryGetValue(def.Key, out var model))
{
context.LogBreakingChange(ComparisonMessages.RemovedProperty, def.Key);
}
Expand Down
Loading