diff --git a/tests/cases/simple/base.json b/tests/cases/simple/base.json index 278c828..0317bf1 100644 --- a/tests/cases/simple/base.json +++ b/tests/cases/simple/base.json @@ -307,6 +307,34 @@ } } } + }, + "/echo": { + "post": { + "operationId": "echo", + "summary": "Echo a shared type", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SharedType" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SharedType" + } + } + } + } + } + } } }, "components": { @@ -539,6 +567,14 @@ ] } ] + }, + "SharedType": { + "type": "object", + "properties": { + "value": { + "type": "string" + } + } } } } diff --git a/tests/cases/simple/output/add-operation.out b/tests/cases/simple/output/add-operation.out index 23d6f9b..753b3e9 100644 --- a/tests/cases/simple/output/add-operation.out +++ b/tests/cases/simple/output/add-operation.out @@ -1,7 +1,7 @@ --- add-operation.json +++ patched @@ - "summary": "Get arrays" + "summary": "Echo a shared type" } }, + "/foo": { diff --git a/tests/cases/simple/output/input-output-schema-change.out b/tests/cases/simple/output/input-output-schema-change.out new file mode 100644 index 0000000..5c74774 --- /dev/null +++ b/tests/cases/simple/output/input-output-schema-change.out @@ -0,0 +1,64 @@ +--- input-output-schema-change.json ++++ patched +@@ + "SharedType": { + "properties": { + "value": { +- "type": "string" ++ "type": "integer" + } + }, + "type": "object" + + +Result for patch: +[ + Change { + paths: [ + ChangePath { + old: [ + "#/components/schemas/SharedType/properties/value", + "#/paths/~1echo/post/request_body/content/application~1json/schema/$ref", + ], + new: [ + "#/components/schemas/SharedType/properties/value", + "#/paths/~1echo/post/request_body/content/application~1json/schema/$ref", + ], + comparison: Input, + }, + ], + changes: [ + ChangeInfo { + old_subpath: "", + new_subpath: "", + message: "schema types changed", + class: Incompatible, + details: UnknownDifference, + }, + ], + }, + Change { + paths: [ + ChangePath { + old: [ + "#/components/schemas/SharedType/properties/value", + "#/paths/~1echo/post/responses/200/content/application~1json/schema/$ref", + ], + new: [ + "#/components/schemas/SharedType/properties/value", + "#/paths/~1echo/post/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + }, + ], + changes: [ + ChangeInfo { + old_subpath: "", + new_subpath: "", + message: "schema types changed", + class: Incompatible, + details: UnknownDifference, + }, + ], + }, +] diff --git a/tests/cases/simple/output/ref-chain-change.out b/tests/cases/simple/output/ref-chain-change.out index 939c83e..c6dec90 100644 --- a/tests/cases/simple/output/ref-chain-change.out +++ b/tests/cases/simple/output/ref-chain-change.out @@ -7,7 +7,7 @@ - "$ref": "#/components/schemas/SubType" + "$ref": "#/components/schemas/ErrorResponse" }, - "SubType": { + "SharedType": { "properties": { diff --git a/tests/cases/simple/output/ref-vs-inline-type-change.out b/tests/cases/simple/output/ref-vs-inline-type-change.out new file mode 100644 index 0000000..38fe82d --- /dev/null +++ b/tests/cases/simple/output/ref-vs-inline-type-change.out @@ -0,0 +1,81 @@ +--- ref-vs-inline-type-change.json ++++ patched +@@ + ] + }, + "via_ref": { +- "$ref": "#/components/schemas/SubType" ++ "properties": { ++ "value": { ++ "type": "integer" ++ } ++ }, ++ "type": "object" + } + }, + "required": [ +@@ + "SubType": { + "properties": { + "value": { +- "type": "string" ++ "type": "integer" + } + }, + "type": "object" + + +Result for patch: +[ + Change { + paths: [ + ChangePath { + old: [ + "#/components/schemas/SubType/properties/value", + "#/components/schemas/GreetingResponse/properties/via_allof/0/$ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new: [ + "#/components/schemas/SubType/properties/value", + "#/components/schemas/GreetingResponse/properties/via_allof/0/$ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + }, + ], + changes: [ + ChangeInfo { + old_subpath: "", + new_subpath: "", + message: "schema types changed", + class: Incompatible, + details: UnknownDifference, + }, + ], + }, + Change { + paths: [ + ChangePath { + old: [ + "#/components/schemas/SubType/properties/value", + "#/components/schemas/GreetingResponse/properties/via_ref/$ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new: [ + "#/components/schemas/GreetingResponse/properties/via_ref/properties/value", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + }, + ], + changes: [ + ChangeInfo { + old_subpath: "", + new_subpath: "", + message: "schema types changed", + class: Incompatible, + details: UnknownDifference, + }, + ], + }, +] diff --git a/tests/cases/simple/output/schema-kind-type-to-oneof.out b/tests/cases/simple/output/schema-kind-type-to-oneof.out index c9753c3..20a03ed 100644 --- a/tests/cases/simple/output/schema-kind-type-to-oneof.out +++ b/tests/cases/simple/output/schema-kind-type-to-oneof.out @@ -1,7 +1,7 @@ --- schema-kind-type-to-oneof.json +++ patched @@ - "$ref": "#/components/schemas/SubType" + "type": "object" }, "SubType": { - "properties": { diff --git a/tests/cases/simple/patch/input-output-schema-change.json b/tests/cases/simple/patch/input-output-schema-change.json new file mode 100644 index 0000000..2442b2a --- /dev/null +++ b/tests/cases/simple/patch/input-output-schema-change.json @@ -0,0 +1,7 @@ +[ + { + "op": "replace", + "path": "/components/schemas/SharedType/properties/value/type", + "value": "integer" + } +] diff --git a/tests/cases/simple/patch/ref-vs-inline-type-change.json b/tests/cases/simple/patch/ref-vs-inline-type-change.json new file mode 100644 index 0000000..8c8181f --- /dev/null +++ b/tests/cases/simple/patch/ref-vs-inline-type-change.json @@ -0,0 +1,19 @@ +[ + { + "op": "replace", + "path": "/components/schemas/SubType/properties/value/type", + "value": "integer" + }, + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_ref", + "value": { + "type": "object", + "properties": { + "value": { + "type": "integer" + } + } + } + } +]