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 0891232
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,51 @@
"Code": "ReferenceRedirection",
"Mode": "Update"
},
{
"Severity": "Warning",
"Message": "The new version has a different discriminator than the previous one.",
"OldJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/discriminator",
"NewJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/discriminator",
"Id": 1030,
"Code": "DifferentDiscriminator",
"Mode": "Update"
},
{
"Severity": "Warning",
"Message": "The new version has a different type \u0027\u0027 than the previous one \u0027object\u0027.",
"OldJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/type",
"NewJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/type",
"Id": 1026,
"Code": "TypeChanged",
"Mode": "Update"
},
{
"Severity": "Warning",
"Message": "The new version has a different \u0027allOf\u0027 property than the previous one.",
"OldJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/allOf",
"NewJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/allOf",
"Id": 1032,
"Code": "DifferentAllOf",
"Mode": "Update"
},
{
"Severity": "Warning",
"Message": "The new version is missing a property found in the old version. Was \u0027name\u0027 renamed or removed?",
"OldJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/properties/name",
"NewJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/properties/name",
"Id": 1033,
"Code": "RemovedProperty",
"Mode": "Removal"
},
{
"Severity": "Warning",
"Message": "The new version is missing a property found in the old version. Was \u0027petType\u0027 renamed or removed?",
"OldJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/properties/petType",
"NewJsonRef": "#/paths/~1api~1Parameters/get/responses/200/content/application~1json/schema/items/properties/petType",
"Id": 1033,
"Code": "RemovedProperty",
"Mode": "Removal"
},
{
"Severity": "Warning",
"Message": "The \u0027$ref\u0027 property points to different models in the old and new versions.",
Expand Down
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 0891232

Please sign in to comment.