diff --git a/src/context.rs b/src/context.rs index 71e0679..04c6c7e 100644 --- a/src/context.rs +++ b/src/context.rs @@ -47,7 +47,7 @@ impl<'a> Context<'a> { } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Contextual<'a, T> { context: Context<'a>, value: T, diff --git a/src/schema.rs b/src/schema.rs index b24e5c0..8dc849d 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -1,5 +1,7 @@ // Copyright 2025 Oxide Computer Company +use std::fmt; + use openapiv3::{AdditionalProperties, ArrayType, ObjectType, ReferenceOr, Schema, SchemaData}; use crate::{ @@ -42,13 +44,139 @@ impl Compare { old_schema: Contextual<'_, &ReferenceOr>, new_schema: Contextual<'_, &ReferenceOr>, ) -> anyhow::Result { - let (old_schema, old_context) = old_schema.contextual_resolve()?; - let (new_schema, new_context) = new_schema.contextual_resolve()?; + // Handle single-element wrappers: allOf/anyOf/oneOf with one item. + // These are semantically equivalent to their inner type. + // + // An allOf wrapper is commonly added to include additional metadata + // such as an additional description field. + if let Some(result) = + self.try_compare_flattened(dry_run, comparison, &old_schema, &new_schema)? + { + Ok(result) + } else { + // General path: resolve and compare. + let (old_schema, old_context) = old_schema.contextual_resolve()?; + let (new_schema, new_context) = new_schema.contextual_resolve()?; + + let old_schema = Contextual::new(old_context, old_schema.as_ref()); + let new_schema = Contextual::new(new_context, new_schema.as_ref()); + + self.compare_schema(comparison, dry_run, old_schema, new_schema) + } + } + + /// Try to compare schemas by flattening single-element wrappers. + /// + /// Returns `Some(result)` if flattening was applicable, `None` to fall + /// through to the general path. + fn try_compare_flattened( + &mut self, + dry_run: bool, + comparison: SchemaComparison, + old_schema: &Contextual<'_, &ReferenceOr>, + new_schema: &Contextual<'_, &ReferenceOr>, + ) -> anyhow::Result> { + use SchemaRefKind::*; - let old_schema = Contextual::new(old_context, old_schema.as_ref()); - let new_schema = Contextual::new(new_context, new_schema.as_ref()); + let old_kind = classify_schema_ref(old_schema.as_ref()); + let new_kind = classify_schema_ref(new_schema.as_ref()); - self.compare_schema(comparison, dry_run, old_schema, new_schema) + match (old_kind, new_kind) { + ( + SingleElement { + inner: old_inner, + metadata: old_meta, + }, + SingleElement { + inner: new_inner, + metadata: new_meta, + }, + ) => { + // Both old and new are single-element wrappers. + if old_meta != new_meta { + self.push_change( + "schema metadata changed", + old_schema, + new_schema, + comparison.into(), + ChangeClass::Trivial, + ChangeDetails::Metadata, + ); + } + let old_inner = old_schema.append_deref(old_inner, "0"); + let new_inner = new_schema.append_deref(new_inner, "0"); + Ok(Some(self.compare_schema_ref_helper( + dry_run, comparison, old_inner, new_inner, + )?)) + } + ( + SingleElement { + inner: old_inner, + metadata: old_meta, + }, + BareRef | InlineType, + ) => { + // Old is a single-element wrapper, new is a bare ref or inline + // type. + // + // A bare ref or inline type does not have metadata, so if the + // old metadata is non-default, report a trivial change. + if has_meaningful_metadata(old_meta) { + self.push_change( + "schema metadata removed", + old_schema, + new_schema, + comparison.into(), + ChangeClass::Trivial, + ChangeDetails::Metadata, + ); + } + let old_inner = old_schema.append_deref(old_inner, "0"); + Ok(Some(self.compare_schema_ref_helper( + dry_run, + comparison, + old_inner, + new_schema.clone(), + )?)) + } + ( + BareRef | InlineType, + SingleElement { + inner: new_inner, + metadata: new_meta, + }, + ) => { + // Old is a bare ref or inline type, new is a single-element + // wrapper. + // + // A bare ref or inline type does not have metadata, so if the + // new metadata is non-default, report a trivial change. + if has_meaningful_metadata(new_meta) { + self.push_change( + "schema metadata added", + old_schema, + new_schema, + comparison.into(), + ChangeClass::Trivial, + ChangeDetails::Metadata, + ); + } + let new_inner = new_schema.append_deref(new_inner, "0"); + Ok(Some(self.compare_schema_ref_helper( + dry_run, + comparison, + old_schema.clone(), + new_inner, + )?)) + } + (BareRef | InlineType | MultiElement, BareRef | InlineType | MultiElement) + | (SingleElement { .. }, MultiElement) + | (MultiElement, SingleElement { .. }) => { + // No flattening applicable, so fall through to the general + // comparison path. + Ok(None) + } + } } fn compare_schema( @@ -215,19 +343,9 @@ impl Compare { openapiv3::SchemaKind::Not { not: old_not }, openapiv3::SchemaKind::Not { not: new_not }, ) => { - if old_not != new_not { - self.schema_push_change( - dry_run, - "unhandled, 'not' schema", - &old_schema_kind, - &new_schema_kind, - comparison, - ChangeClass::Unhandled, - ChangeDetails::UnknownDifference, - ) - } else { - Ok(true) - } + let old_not = old_schema_kind.append_deref(old_not.as_ref(), "not"); + let new_not = new_schema_kind.append_deref(new_not.as_ref(), "not"); + self.compare_schema_ref_helper(dry_run, comparison, old_not, new_not) } (&openapiv3::SchemaKind::Any(old_any), &openapiv3::SchemaKind::Any(new_any)) => { if old_any == new_any { @@ -244,15 +362,19 @@ impl Compare { ) } } - _ => self.schema_push_change( - dry_run, - "schema kinds changed".to_string(), - &old_schema_kind, - &new_schema_kind, - comparison, - ChangeClass::Incompatible, - ChangeDetails::Datatype, - ), + _ => { + let old_tag = SchemaKindTag::new(&old_schema_kind); + let new_tag = SchemaKindTag::new(&new_schema_kind); + self.schema_push_change( + dry_run, + format!("schema kind changed from {} to {}", old_tag, new_tag), + &old_schema_kind, + &new_schema_kind, + comparison, + ChangeClass::Incompatible, + ChangeDetails::Datatype, + ) + } } } @@ -668,3 +790,99 @@ impl Compare { Ok(false) } } + +#[derive(Clone, Debug)] +enum SchemaKindTag { + Type, + OneOf, + AllOf, + AnyOf, + Not, + Any, +} + +impl fmt::Display for SchemaKindTag { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Type => write!(f, "regular type"), + Self::OneOf => write!(f, "oneOf"), + Self::AllOf => write!(f, "allOf"), + Self::AnyOf => write!(f, "anyOf"), + Self::Not => write!(f, "not"), + Self::Any => write!(f, "any"), + } + } +} + +impl SchemaKindTag { + fn new(kind: &openapiv3::SchemaKind) -> Self { + match kind { + openapiv3::SchemaKind::Type(_) => Self::Type, + openapiv3::SchemaKind::OneOf { .. } => Self::OneOf, + openapiv3::SchemaKind::AllOf { .. } => Self::AllOf, + openapiv3::SchemaKind::AnyOf { .. } => Self::AnyOf, + openapiv3::SchemaKind::Not { .. } => Self::Not, + openapiv3::SchemaKind::Any { .. } => Self::Any, + } + } +} + +/// Classification of a schema reference for flattening purposes. +enum SchemaRefKind<'a> { + /// A bare $ref. + BareRef, + /// An inline type (Type, Any, Not). + /// + /// It is okay to compare something like Not with single-element wrappers. + /// When recursing, we'll ensure that the child is also Not. + InlineType, + /// A single-element allOf/anyOf/oneOf wrapper that can be flattened to its + /// inner type. + SingleElement { + inner: &'a ReferenceOr, + metadata: &'a SchemaData, + }, + /// Multi (or, less commonly, zero) element allOf/anyOf/oneOf: cannot be + /// flattened. + MultiElement, +} + +/// Classify a schema reference for flattening purposes. +fn classify_schema_ref(schema_ref: &ReferenceOr) -> SchemaRefKind<'_> { + match schema_ref { + ReferenceOr::Reference { .. } => SchemaRefKind::BareRef, + ReferenceOr::Item(schema) => match &schema.schema_kind { + openapiv3::SchemaKind::Type(_) + | openapiv3::SchemaKind::Not { .. } + | openapiv3::SchemaKind::Any(_) => SchemaRefKind::InlineType, + openapiv3::SchemaKind::AllOf { all_of } if all_of.len() == 1 => { + SchemaRefKind::SingleElement { + inner: all_of.first().unwrap(), + metadata: &schema.schema_data, + } + } + openapiv3::SchemaKind::AnyOf { any_of } if any_of.len() == 1 => { + SchemaRefKind::SingleElement { + inner: any_of.first().unwrap(), + metadata: &schema.schema_data, + } + } + openapiv3::SchemaKind::OneOf { one_of } if one_of.len() == 1 => { + SchemaRefKind::SingleElement { + inner: one_of.first().unwrap(), + metadata: &schema.schema_data, + } + } + // Multi-element wrappers - not semantically equivalent to single schemas. + openapiv3::SchemaKind::AllOf { .. } + | openapiv3::SchemaKind::AnyOf { .. } + | openapiv3::SchemaKind::OneOf { .. } => SchemaRefKind::MultiElement, + }, + } +} + +/// Check if schema_data has any non-default values that would constitute +/// metadata worth preserving. +fn has_meaningful_metadata(data: &SchemaData) -> bool { + *data != SchemaData::default() +} diff --git a/tests/cases/simple/base.json b/tests/cases/simple/base.json index 1cd9aa0..6b7b876 100644 --- a/tests/cases/simple/base.json +++ b/tests/cases/simple/base.json @@ -80,12 +80,52 @@ "message": { "type": "string", "description": "The greeting message" + }, + "via_ref": { + "$ref": "#/components/schemas/SubType" + }, + "via_allof": { + "description": "Via allOf.", + "allOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + }, + "via_anyof": { + "description": "Via anyOf.", + "anyOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + }, + "via_oneof": { + "description": "Via oneOf.", + "oneOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + }, + "not_a_number": { + "not": { + "type": "number" + } } }, "required": [ "message" ] }, + "SubType": { + "type": "object", + "properties": { + "value": { + "type": "string" + } + } + }, "Tree": { "type": "object", "properties": { diff --git a/tests/cases/simple/output/add-operation.out b/tests/cases/simple/output/add-operation.out index 0dd6a8a..e1aa2c1 100644 --- a/tests/cases/simple/output/add-operation.out +++ b/tests/cases/simple/output/add-operation.out @@ -1,6 +1,6 @@ --- add-operation.json +++ patched -@@ -33,6 +33,16 @@ +@@ -73,6 +73,16 @@ }, "openapi": "3.0.0", "paths": { diff --git a/tests/cases/simple/output/add-type-extension.out b/tests/cases/simple/output/add-type-extension.out index 8d01c23..043ebc5 100644 --- a/tests/cases/simple/output/add-type-extension.out +++ b/tests/cases/simple/output/add-type-extension.out @@ -1,6 +1,6 @@ --- add-type-extension.json +++ patched -@@ -11,7 +11,10 @@ +@@ -43,7 +43,10 @@ "required": [ "message" ], @@ -10,7 +10,7 @@ + "mumble": "frotz" + } }, - "Tree": { + "SubType": { "properties": { diff --git a/tests/cases/simple/output/allof-to-anyof.out b/tests/cases/simple/output/allof-to-anyof.out new file mode 100644 index 0000000..340e4c8 --- /dev/null +++ b/tests/cases/simple/output/allof-to-anyof.out @@ -0,0 +1,36 @@ +--- allof-to-anyof.json ++++ patched +@@ -13,12 +13,12 @@ + } + }, + "via_allof": { +- "allOf": [ ++ "anyOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ], +- "description": "Via allOf." ++ "description": "Via anyOf." + }, + "via_anyof": { + "anyOf": [ + + +Result for patch: +[ + Change { + message: "schema metadata changed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/allof-to-oneof-with-type-change.out b/tests/cases/simple/output/allof-to-oneof-with-type-change.out new file mode 100644 index 0000000..9f7fe5b --- /dev/null +++ b/tests/cases/simple/output/allof-to-oneof-with-type-change.out @@ -0,0 +1,62 @@ +--- allof-to-oneof-with-type-change.json ++++ patched +@@ -13,12 +13,12 @@ + } + }, + "via_allof": { +- "allOf": [ ++ "description": "Via oneOf.", ++ "oneOf": [ + { + "$ref": "#/components/schemas/SubType" + } +- ], +- "description": "Via allOf." ++ ] + }, + "via_anyof": { + "anyOf": [ +@@ -48,7 +48,7 @@ + "SubType": { + "properties": { + "value": { +- "type": "string" ++ "type": "integer" + } + }, + "type": "object" + + +Result for patch: +[ + Change { + message: "schema metadata changed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, + Change { + message: "schema types changed", + old_path: [ + "#/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_path: [ + "#/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, + class: Incompatible, + details: UnknownDifference, + }, +] diff --git a/tests/cases/simple/output/allof-to-oneof.out b/tests/cases/simple/output/allof-to-oneof.out new file mode 100644 index 0000000..a9da088 --- /dev/null +++ b/tests/cases/simple/output/allof-to-oneof.out @@ -0,0 +1,37 @@ +--- allof-to-oneof.json ++++ patched +@@ -13,12 +13,12 @@ + } + }, + "via_allof": { +- "allOf": [ ++ "description": "Via oneOf.", ++ "oneOf": [ + { + "$ref": "#/components/schemas/SubType" + } +- ], +- "description": "Via allOf." ++ ] + }, + "via_anyof": { + "anyOf": [ + + +Result for patch: +[ + Change { + message: "schema metadata changed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/allof-to-ref-with-type-change.out b/tests/cases/simple/output/allof-to-ref-with-type-change.out new file mode 100644 index 0000000..5d46eca --- /dev/null +++ b/tests/cases/simple/output/allof-to-ref-with-type-change.out @@ -0,0 +1,61 @@ +--- allof-to-ref-with-type-change.json ++++ patched +@@ -13,12 +13,7 @@ + } + }, + "via_allof": { +- "allOf": [ +- { +- "$ref": "#/components/schemas/SubType" +- } +- ], +- "description": "Via allOf." ++ "$ref": "#/components/schemas/SubType" + }, + "via_anyof": { + "anyOf": [ +@@ -47,6 +42,9 @@ + }, + "SubType": { + "properties": { ++ "extra": { ++ "type": "integer" ++ }, + "value": { + "type": "string" + } + + +Result for patch: +[ + Change { + message: "schema metadata removed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, + Change { + message: "object properties changed", + old_path: [ + "#/components/schemas/SubType", + "#/components/schemas/GreetingResponse/properties/via_allof/0/$ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/SubType", + "#/components/schemas/GreetingResponse/properties/via_allof/$ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Unhandled, + details: UnknownDifference, + }, +] diff --git a/tests/cases/simple/output/allof-to-ref.out b/tests/cases/simple/output/allof-to-ref.out new file mode 100644 index 0000000..208cd01 --- /dev/null +++ b/tests/cases/simple/output/allof-to-ref.out @@ -0,0 +1,35 @@ +--- allof-to-ref.json ++++ patched +@@ -13,12 +13,7 @@ + } + }, + "via_allof": { +- "allOf": [ +- { +- "$ref": "#/components/schemas/SubType" +- } +- ], +- "description": "Via allOf." ++ "$ref": "#/components/schemas/SubType" + }, + "via_anyof": { + "anyOf": [ + + +Result for patch: +[ + Change { + message: "schema metadata removed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_allof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/anyof-to-allof.out b/tests/cases/simple/output/anyof-to-allof.out new file mode 100644 index 0000000..3b79c72 --- /dev/null +++ b/tests/cases/simple/output/anyof-to-allof.out @@ -0,0 +1,36 @@ +--- anyof-to-allof.json ++++ patched +@@ -21,12 +21,12 @@ + "description": "Via allOf." + }, + "via_anyof": { +- "anyOf": [ ++ "allOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ], +- "description": "Via anyOf." ++ "description": "Via allOf." + }, + "via_oneof": { + "description": "Via oneOf.", + + +Result for patch: +[ + Change { + message: "schema metadata changed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_anyof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_anyof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/anyof-to-oneof.out b/tests/cases/simple/output/anyof-to-oneof.out new file mode 100644 index 0000000..30f4d9e --- /dev/null +++ b/tests/cases/simple/output/anyof-to-oneof.out @@ -0,0 +1,37 @@ +--- anyof-to-oneof.json ++++ patched +@@ -21,12 +21,12 @@ + "description": "Via allOf." + }, + "via_anyof": { +- "anyOf": [ ++ "description": "Via oneOf.", ++ "oneOf": [ + { + "$ref": "#/components/schemas/SubType" + } +- ], +- "description": "Via anyOf." ++ ] + }, + "via_oneof": { + "description": "Via oneOf.", + + +Result for patch: +[ + Change { + message: "schema metadata changed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_anyof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_anyof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/anyof-to-ref.out b/tests/cases/simple/output/anyof-to-ref.out new file mode 100644 index 0000000..c1a38bd --- /dev/null +++ b/tests/cases/simple/output/anyof-to-ref.out @@ -0,0 +1,35 @@ +--- anyof-to-ref.json ++++ patched +@@ -21,12 +21,7 @@ + "description": "Via allOf." + }, + "via_anyof": { +- "anyOf": [ +- { +- "$ref": "#/components/schemas/SubType" +- } +- ], +- "description": "Via anyOf." ++ "$ref": "#/components/schemas/SubType" + }, + "via_oneof": { + "description": "Via oneOf.", + + +Result for patch: +[ + Change { + message: "schema metadata removed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_anyof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_anyof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/change-operation-parameter-requirement.out b/tests/cases/simple/output/change-operation-parameter-requirement.out index d8437ac..4cb3afe 100644 --- a/tests/cases/simple/output/change-operation-parameter-requirement.out +++ b/tests/cases/simple/output/change-operation-parameter-requirement.out @@ -1,6 +1,6 @@ --- change-operation-parameter-requirement.json +++ patched -@@ -48,7 +48,7 @@ +@@ -88,7 +88,7 @@ "description": "Language for the greeting", "in": "query", "name": "language", diff --git a/tests/cases/simple/output/change-operation-parameter-type.out b/tests/cases/simple/output/change-operation-parameter-type.out index 2c918f1..a37355d 100644 --- a/tests/cases/simple/output/change-operation-parameter-type.out +++ b/tests/cases/simple/output/change-operation-parameter-type.out @@ -1,6 +1,6 @@ --- change-operation-parameter-type.json +++ patched -@@ -50,7 +50,7 @@ +@@ -90,7 +90,7 @@ "name": "language", "required": false, "schema": { diff --git a/tests/cases/simple/output/change-property-type.out b/tests/cases/simple/output/change-property-type.out index 7ea9e2a..849276a 100644 --- a/tests/cases/simple/output/change-property-type.out +++ b/tests/cases/simple/output/change-property-type.out @@ -6,9 +6,9 @@ "description": "The greeting message", - "type": "string" + "type": "integer" - } - }, - "required": [ + }, + "not_a_number": { + "not": { Result for patch: diff --git a/tests/cases/simple/output/inline-to-allof.out b/tests/cases/simple/output/inline-to-allof.out new file mode 100644 index 0000000..990a799 --- /dev/null +++ b/tests/cases/simple/output/inline-to-allof.out @@ -0,0 +1,33 @@ +--- inline-to-allof.json ++++ patched +@@ -81,7 +81,12 @@ + "in": "path", + "name": "name", + "schema": { +- "type": "string" ++ "allOf": [ ++ { ++ "type": "string" ++ } ++ ], ++ "description": "A string parameter" + } + }, + { + + +Result for patch: +[ + Change { + message: "schema metadata added", + old_path: [ + "#/paths/~1hello~1{name}/get/parameters/0/schema", + ], + new_path: [ + "#/paths/~1hello~1{name}/get/parameters/0/schema", + ], + comparison: Input, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/modify-cycle-type.out b/tests/cases/simple/output/modify-cycle-type.out index e9b0596..2048834 100644 --- a/tests/cases/simple/output/modify-cycle-type.out +++ b/tests/cases/simple/output/modify-cycle-type.out @@ -1,6 +1,6 @@ --- modify-cycle-type.json +++ patched -@@ -16,10 +16,7 @@ +@@ -56,10 +56,7 @@ "Tree": { "properties": { "children": { diff --git a/tests/cases/simple/output/not-inner-to-allof.out b/tests/cases/simple/output/not-inner-to-allof.out new file mode 100644 index 0000000..98295ff --- /dev/null +++ b/tests/cases/simple/output/not-inner-to-allof.out @@ -0,0 +1,35 @@ +--- not-inner-to-allof.json ++++ patched +@@ -9,7 +9,12 @@ + }, + "not_a_number": { + "not": { +- "type": "number" ++ "allOf": [ ++ { ++ "type": "number" ++ } ++ ], ++ "description": "A number type" + } + }, + "via_allof": { + + +Result for patch: +[ + Change { + message: "schema metadata added", + old_path: [ + "#/components/schemas/GreetingResponse/properties/not_a_number/not", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/not_a_number/not", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/not-to-allof.out b/tests/cases/simple/output/not-to-allof.out new file mode 100644 index 0000000..a088c44 --- /dev/null +++ b/tests/cases/simple/output/not-to-allof.out @@ -0,0 +1,39 @@ +--- not-to-allof.json ++++ patched +@@ -8,9 +8,14 @@ + "type": "string" + }, + "not_a_number": { +- "not": { +- "type": "number" +- } ++ "allOf": [ ++ { ++ "not": { ++ "type": "number" ++ } ++ } ++ ], ++ "description": "Not a number, wrapped in allOf" + }, + "via_allof": { + "allOf": [ + + +Result for patch: +[ + Change { + message: "schema metadata added", + old_path: [ + "#/components/schemas/GreetingResponse/properties/not_a_number", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/not_a_number", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/oneof-to-allof.out b/tests/cases/simple/output/oneof-to-allof.out new file mode 100644 index 0000000..b67b769 --- /dev/null +++ b/tests/cases/simple/output/oneof-to-allof.out @@ -0,0 +1,37 @@ +--- oneof-to-allof.json ++++ patched +@@ -29,12 +29,12 @@ + "description": "Via anyOf." + }, + "via_oneof": { +- "description": "Via oneOf.", +- "oneOf": [ ++ "allOf": [ + { + "$ref": "#/components/schemas/SubType" + } +- ] ++ ], ++ "description": "Via allOf." + }, + "via_ref": { + "$ref": "#/components/schemas/SubType" + + +Result for patch: +[ + Change { + message: "schema metadata changed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_oneof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_oneof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/oneof-to-anyof.out b/tests/cases/simple/output/oneof-to-anyof.out new file mode 100644 index 0000000..fcd4fa2 --- /dev/null +++ b/tests/cases/simple/output/oneof-to-anyof.out @@ -0,0 +1,37 @@ +--- oneof-to-anyof.json ++++ patched +@@ -29,12 +29,12 @@ + "description": "Via anyOf." + }, + "via_oneof": { +- "description": "Via oneOf.", +- "oneOf": [ ++ "anyOf": [ + { + "$ref": "#/components/schemas/SubType" + } +- ] ++ ], ++ "description": "Via anyOf." + }, + "via_ref": { + "$ref": "#/components/schemas/SubType" + + +Result for patch: +[ + Change { + message: "schema metadata changed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_oneof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_oneof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/oneof-to-ref.out b/tests/cases/simple/output/oneof-to-ref.out new file mode 100644 index 0000000..b173144 --- /dev/null +++ b/tests/cases/simple/output/oneof-to-ref.out @@ -0,0 +1,35 @@ +--- oneof-to-ref.json ++++ patched +@@ -29,12 +29,7 @@ + "description": "Via anyOf." + }, + "via_oneof": { +- "description": "Via oneOf.", +- "oneOf": [ +- { +- "$ref": "#/components/schemas/SubType" +- } +- ] ++ "$ref": "#/components/schemas/SubType" + }, + "via_ref": { + "$ref": "#/components/schemas/SubType" + + +Result for patch: +[ + Change { + message: "schema metadata removed", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_oneof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_oneof", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/ref-to-allof.out b/tests/cases/simple/output/ref-to-allof.out new file mode 100644 index 0000000..b02467c --- /dev/null +++ b/tests/cases/simple/output/ref-to-allof.out @@ -0,0 +1,35 @@ +--- ref-to-allof.json ++++ patched +@@ -37,7 +37,12 @@ + ] + }, + "via_ref": { +- "$ref": "#/components/schemas/SubType" ++ "allOf": [ ++ { ++ "$ref": "#/components/schemas/SubType" ++ } ++ ], ++ "description": "Via allOf." + } + }, + "required": [ + + +Result for patch: +[ + Change { + message: "schema metadata added", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/ref-to-anyof.out b/tests/cases/simple/output/ref-to-anyof.out new file mode 100644 index 0000000..fe43f29 --- /dev/null +++ b/tests/cases/simple/output/ref-to-anyof.out @@ -0,0 +1,35 @@ +--- ref-to-anyof.json ++++ patched +@@ -37,7 +37,12 @@ + ] + }, + "via_ref": { +- "$ref": "#/components/schemas/SubType" ++ "anyOf": [ ++ { ++ "$ref": "#/components/schemas/SubType" ++ } ++ ], ++ "description": "Via anyOf." + } + }, + "required": [ + + +Result for patch: +[ + Change { + message: "schema metadata added", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/ref-to-inline-allof.out b/tests/cases/simple/output/ref-to-inline-allof.out new file mode 100644 index 0000000..fb1fd7b --- /dev/null +++ b/tests/cases/simple/output/ref-to-inline-allof.out @@ -0,0 +1,56 @@ +--- ref-to-inline-allof.json ++++ patched +@@ -37,7 +37,18 @@ + ] + }, + "via_ref": { +- "$ref": "#/components/schemas/SubType" ++ "allOf": [ ++ { ++ "description": "Greeting response type", ++ "properties": { ++ "value": { ++ "type": "string" ++ } ++ }, ++ "type": "object" ++ } ++ ], ++ "description": "A greeting response" + } + }, + "required": [ + + +Result for patch: +[ + Change { + message: "schema metadata added", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, + Change { + message: "schema metadata changed", + old_path: [ + "#/components/schemas/SubType", + "#/components/schemas/GreetingResponse/properties/via_ref/$ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_ref/0", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/ref-to-oneof.out b/tests/cases/simple/output/ref-to-oneof.out new file mode 100644 index 0000000..66f1a29 --- /dev/null +++ b/tests/cases/simple/output/ref-to-oneof.out @@ -0,0 +1,35 @@ +--- ref-to-oneof.json ++++ patched +@@ -37,7 +37,12 @@ + ] + }, + "via_ref": { +- "$ref": "#/components/schemas/SubType" ++ "description": "Via oneOf.", ++ "oneOf": [ ++ { ++ "$ref": "#/components/schemas/SubType" ++ } ++ ] + } + }, + "required": [ + + +Result for patch: +[ + Change { + message: "schema metadata added", + old_path: [ + "#/components/schemas/GreetingResponse/properties/via_ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + new_path: [ + "#/components/schemas/GreetingResponse/properties/via_ref", + "#/paths/~1hello~1{name}/get/responses/200/content/application~1json/schema/$ref", + ], + comparison: Output, + class: Trivial, + details: Metadata, + }, +] diff --git a/tests/cases/simple/output/remove-operation-parameter.out b/tests/cases/simple/output/remove-operation-parameter.out index f7b90e2..f327dd7 100644 --- a/tests/cases/simple/output/remove-operation-parameter.out +++ b/tests/cases/simple/output/remove-operation-parameter.out @@ -1,6 +1,6 @@ --- remove-operation-parameter.json +++ patched -@@ -43,15 +43,6 @@ +@@ -83,15 +83,6 @@ "schema": { "type": "string" } diff --git a/tests/cases/simple/output/remove-operation.out b/tests/cases/simple/output/remove-operation.out index 06d2ddb..87f6495 100644 --- a/tests/cases/simple/output/remove-operation.out +++ b/tests/cases/simple/output/remove-operation.out @@ -1,6 +1,6 @@ --- remove-operation.json +++ patched -@@ -69,18 +69,7 @@ +@@ -109,18 +109,7 @@ "summary": "Say hello" } }, diff --git a/tests/cases/simple/output/type-indirection.out b/tests/cases/simple/output/type-indirection.out index be61afb..07df301 100644 --- a/tests/cases/simple/output/type-indirection.out +++ b/tests/cases/simple/output/type-indirection.out @@ -7,10 +7,10 @@ - "description": "The greeting message", - "type": "string" + "$ref": "#/components/schemas/GreetingResponseMessage" - } - }, - "required": [ -@@ -13,6 +12,13 @@ + }, + "not_a_number": { + "not": { +@@ -45,6 +44,13 @@ ], "type": "object" }, @@ -21,9 +21,9 @@ + "jank": true + } + }, - "Tree": { + "SubType": { "properties": { - "children": { + "value": { Result for patch: diff --git a/tests/cases/simple/output/type-rename.out b/tests/cases/simple/output/type-rename.out index bfbf873..df8d69b 100644 --- a/tests/cases/simple/output/type-rename.out +++ b/tests/cases/simple/output/type-rename.out @@ -9,7 +9,7 @@ "properties": { "message": { "description": "The greeting message", -@@ -59,7 +59,7 @@ +@@ -99,7 +99,7 @@ "content": { "application/json": { "schema": { diff --git a/tests/cases/simple/output/unhandled-add-prop.out b/tests/cases/simple/output/unhandled-add-prop.out index 93a407f..231da94 100644 --- a/tests/cases/simple/output/unhandled-add-prop.out +++ b/tests/cases/simple/output/unhandled-add-prop.out @@ -1,13 +1,17 @@ --- unhandled-add-prop.json +++ patched -@@ -6,10 +6,15 @@ - "message": { - "description": "The greeting message", - "type": "string" -+ }, +@@ -12,6 +12,10 @@ + "type": "number" + } + }, + "source": { + "description": "Where the greeting originated", + "type": "string" ++ }, + "via_allof": { + "allOf": [ + { +@@ -41,7 +45,8 @@ } }, "required": [ diff --git a/tests/cases/simple/output/wrapper-unchanged-with-type-change.out b/tests/cases/simple/output/wrapper-unchanged-with-type-change.out new file mode 100644 index 0000000..14a036b --- /dev/null +++ b/tests/cases/simple/output/wrapper-unchanged-with-type-change.out @@ -0,0 +1,32 @@ +--- wrapper-unchanged-with-type-change.json ++++ patched +@@ -48,7 +48,7 @@ + "SubType": { + "properties": { + "value": { +- "type": "string" ++ "type": "integer" + } + }, + "type": "object" + + +Result for patch: +[ + Change { + message: "schema types changed", + old_path: [ + "#/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_path: [ + "#/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, + class: Incompatible, + details: UnknownDifference, + }, +] diff --git a/tests/cases/simple/patch/allof-to-anyof.json b/tests/cases/simple/patch/allof-to-anyof.json new file mode 100644 index 0000000..f7e8bea --- /dev/null +++ b/tests/cases/simple/patch/allof-to-anyof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_allof", + "value": { + "description": "Via anyOf.", + "anyOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/allof-to-oneof-with-type-change.json b/tests/cases/simple/patch/allof-to-oneof-with-type-change.json new file mode 100644 index 0000000..1b973c6 --- /dev/null +++ b/tests/cases/simple/patch/allof-to-oneof-with-type-change.json @@ -0,0 +1,19 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_allof", + "value": { + "description": "Via oneOf.", + "oneOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + }, + { + "op": "replace", + "path": "/components/schemas/SubType/properties/value/type", + "value": "integer" + } +] diff --git a/tests/cases/simple/patch/allof-to-oneof.json b/tests/cases/simple/patch/allof-to-oneof.json new file mode 100644 index 0000000..6ba1e82 --- /dev/null +++ b/tests/cases/simple/patch/allof-to-oneof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_allof", + "value": { + "description": "Via oneOf.", + "oneOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/allof-to-ref-with-type-change.json b/tests/cases/simple/patch/allof-to-ref-with-type-change.json new file mode 100644 index 0000000..f5d0da9 --- /dev/null +++ b/tests/cases/simple/patch/allof-to-ref-with-type-change.json @@ -0,0 +1,16 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_allof", + "value": { + "$ref": "#/components/schemas/SubType" + } + }, + { + "op": "add", + "path": "/components/schemas/SubType/properties/extra", + "value": { + "type": "integer" + } + } +] diff --git a/tests/cases/simple/patch/allof-to-ref.json b/tests/cases/simple/patch/allof-to-ref.json new file mode 100644 index 0000000..a5a5da7 --- /dev/null +++ b/tests/cases/simple/patch/allof-to-ref.json @@ -0,0 +1,9 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_allof", + "value": { + "$ref": "#/components/schemas/SubType" + } + } +] diff --git a/tests/cases/simple/patch/anyof-to-allof.json b/tests/cases/simple/patch/anyof-to-allof.json new file mode 100644 index 0000000..94a4eb6 --- /dev/null +++ b/tests/cases/simple/patch/anyof-to-allof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_anyof", + "value": { + "description": "Via allOf.", + "allOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/anyof-to-oneof.json b/tests/cases/simple/patch/anyof-to-oneof.json new file mode 100644 index 0000000..40ed32f --- /dev/null +++ b/tests/cases/simple/patch/anyof-to-oneof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_anyof", + "value": { + "description": "Via oneOf.", + "oneOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/anyof-to-ref.json b/tests/cases/simple/patch/anyof-to-ref.json new file mode 100644 index 0000000..20c364b --- /dev/null +++ b/tests/cases/simple/patch/anyof-to-ref.json @@ -0,0 +1,9 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_anyof", + "value": { + "$ref": "#/components/schemas/SubType" + } + } +] diff --git a/tests/cases/simple/patch/inline-to-allof.json b/tests/cases/simple/patch/inline-to-allof.json new file mode 100644 index 0000000..8efe6df --- /dev/null +++ b/tests/cases/simple/patch/inline-to-allof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/paths/~1hello~1{name}/get/parameters/0/schema", + "value": { + "description": "A string parameter", + "allOf": [ + { + "type": "string" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/not-inner-to-allof.json b/tests/cases/simple/patch/not-inner-to-allof.json new file mode 100644 index 0000000..cbef6d6 --- /dev/null +++ b/tests/cases/simple/patch/not-inner-to-allof.json @@ -0,0 +1,16 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/not_a_number", + "value": { + "not": { + "description": "A number type", + "allOf": [ + { + "type": "number" + } + ] + } + } + } +] diff --git a/tests/cases/simple/patch/not-to-allof.json b/tests/cases/simple/patch/not-to-allof.json new file mode 100644 index 0000000..cffcccf --- /dev/null +++ b/tests/cases/simple/patch/not-to-allof.json @@ -0,0 +1,16 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/not_a_number", + "value": { + "description": "Not a number, wrapped in allOf", + "allOf": [ + { + "not": { + "type": "number" + } + } + ] + } + } +] diff --git a/tests/cases/simple/patch/oneof-to-allof.json b/tests/cases/simple/patch/oneof-to-allof.json new file mode 100644 index 0000000..f5e1433 --- /dev/null +++ b/tests/cases/simple/patch/oneof-to-allof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_oneof", + "value": { + "description": "Via allOf.", + "allOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/oneof-to-anyof.json b/tests/cases/simple/patch/oneof-to-anyof.json new file mode 100644 index 0000000..5ff8d9f --- /dev/null +++ b/tests/cases/simple/patch/oneof-to-anyof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_oneof", + "value": { + "description": "Via anyOf.", + "anyOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/oneof-to-ref.json b/tests/cases/simple/patch/oneof-to-ref.json new file mode 100644 index 0000000..6733d03 --- /dev/null +++ b/tests/cases/simple/patch/oneof-to-ref.json @@ -0,0 +1,9 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_oneof", + "value": { + "$ref": "#/components/schemas/SubType" + } + } +] diff --git a/tests/cases/simple/patch/ref-to-allof.json b/tests/cases/simple/patch/ref-to-allof.json new file mode 100644 index 0000000..aa4ff22 --- /dev/null +++ b/tests/cases/simple/patch/ref-to-allof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_ref", + "value": { + "description": "Via allOf.", + "allOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/ref-to-anyof.json b/tests/cases/simple/patch/ref-to-anyof.json new file mode 100644 index 0000000..e2da503 --- /dev/null +++ b/tests/cases/simple/patch/ref-to-anyof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_ref", + "value": { + "description": "Via anyOf.", + "anyOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/ref-to-inline-allof.json b/tests/cases/simple/patch/ref-to-inline-allof.json new file mode 100644 index 0000000..de10b3c --- /dev/null +++ b/tests/cases/simple/patch/ref-to-inline-allof.json @@ -0,0 +1,20 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_ref", + "value": { + "description": "A greeting response", + "allOf": [ + { + "type": "object", + "description": "Greeting response type", + "properties": { + "value": { + "type": "string" + } + } + } + ] + } + } +] diff --git a/tests/cases/simple/patch/ref-to-oneof.json b/tests/cases/simple/patch/ref-to-oneof.json new file mode 100644 index 0000000..8df1cec --- /dev/null +++ b/tests/cases/simple/patch/ref-to-oneof.json @@ -0,0 +1,14 @@ +[ + { + "op": "replace", + "path": "/components/schemas/GreetingResponse/properties/via_ref", + "value": { + "description": "Via oneOf.", + "oneOf": [ + { + "$ref": "#/components/schemas/SubType" + } + ] + } + } +] diff --git a/tests/cases/simple/patch/wrapper-unchanged-with-type-change.json b/tests/cases/simple/patch/wrapper-unchanged-with-type-change.json new file mode 100644 index 0000000..efd7b78 --- /dev/null +++ b/tests/cases/simple/patch/wrapper-unchanged-with-type-change.json @@ -0,0 +1,7 @@ +[ + { + "op": "replace", + "path": "/components/schemas/SubType/properties/value/type", + "value": "integer" + } +]