diff --git a/CHANGELOG.md b/CHANGELOG.md index e0dc59f8..8d2be79f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ For a full diff see [`2.0.0...2.1.0`][2.0.0...2.1.0]. ### Changed - Adjusted `SchemaNormalizer` to support `anyOf` ([#623]), by [@localheinz] +- Stopped checking whether `type` property in schema is set to `array` or `object` ([#632]), by [@localheinz] ## [`2.0.0`][2.0.0] @@ -461,6 +462,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0]. [#618]: https://github.com/ergebnis/json-normalizer/pull/618 [#619]: https://github.com/ergebnis/json-normalizer/pull/619 [#623]: https://github.com/ergebnis/json-normalizer/pull/623 +[#632]: https://github.com/ergebnis/json-normalizer/pull/632 [@BackEndTea]: https://github.com/BackEndTea [@dependabot]: https://github.com/dependabot diff --git a/src/SchemaNormalizer.php b/src/SchemaNormalizer.php index 67745587..ff8929b8 100644 --- a/src/SchemaNormalizer.php +++ b/src/SchemaNormalizer.php @@ -131,13 +131,6 @@ private function normalizeArray( $schema, ); - /** - * @see https://json-schema.org/understanding-json-schema/reference/array.html - */ - if (!self::describesType('array', $schema)) { - return $data; - } - /** * @see https://json-schema.org/understanding-json-schema/reference/array.html#items */ @@ -179,13 +172,6 @@ private function normalizeObject( $schema, ); - /** - * @see https://json-schema.org/understanding-json-schema/reference/object.html - */ - if (!self::describesType('object', $schema)) { - return $data; - } - /** * @see https://json-schema.org/understanding-json-schema/reference/object.html#properties */ @@ -298,22 +284,4 @@ private function resolveSchema( return $schema; } - - /** - * @see https://json-schema.org/understanding-json-schema/reference/type.html - */ - private static function describesType( - string $type, - \stdClass $schema - ): bool { - if (!\property_exists($schema, 'type')) { - return false; - } - - if ($schema->type === $type) { - return true; - } - - return \is_array($schema->type) && \in_array($type, $schema->type, true); - } }