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 11, 2024
1 parent 81e7b42 commit f2675ac
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"Severity": "Warning",
"Message": "The \u0027$ref\u0027 property points to different models in the old and new versions.",
"OldJsonRef": "#/paths/~1orders/get/responses/200/content/application~1json/schema/items",
"NewJsonRef": "#/paths/~1orders/get/responses/200/content/application~1json/schema/items",
"Id": 1017,
"Code": "ReferenceRedirection",
"Mode": "Update"
},
{
"Severity": "Warning",
"Message": "The new version has a different type \u0027string\u0027 than the previous one \u0027integer\u0027.",
"OldJsonRef": "#/paths/~1orders/get/responses/200/content/application~1json/schema/items/properties/id/type",
"NewJsonRef": "#/paths/~1orders/get/responses/200/content/application~1json/schema/items/properties/id/type",
"Id": 1026,
"Code": "TypeChanged",
"Mode": "Update"
},
{
"Severity": "Warning",
"Message": "The new version is missing a definition that was found in the old version. Was \u0027Order\u0027 removed or renamed?",
"OldJsonRef": "#/schemas/Order",
"NewJsonRef": "#/schemas/Order",
"Id": 1006,
"Code": "RemovedDefinition",
"Mode": "Removal"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
openapi: 3.0.0
info:
title: My API
version: 0.2.0
paths:
/orders:
get:
responses:
"200":
description: Successful Response
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Commande"
components:
schemas:
Commande:
type: object
properties:
id:
type: string
name:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
openapi: 3.0.0
info:
title: My API
version: 0.1.0
paths:
/orders:
get:
responses:
"200":
description: Successful Response
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Order"
components:
schemas:
Order:
type: object
properties:
id:
type: integer
name:
type: string
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

0 comments on commit f2675ac

Please sign in to comment.