Closed JohnRDOrazio closed 4 months ago
Strange thing, when creating a minimal example like the one posted the test is passing. When validating real data I'm getting the "object expected" error. But since it's not always reproducible I'm going to close for now..
This issue can be deleted. After careful inspection of the code that was generating an error, I finally found a wrong variable that was pointing to the wrong schema. Error on my part.
I have been happily using this library to validate general JSON schemas, and not just Open API schemas. However I have just come across a strange issue: if I have a schema that has type
array
as its base, the schema fails to validate because it seems to want an object in any case. It doesn't want to let me have an array as the base.Example data:
Schema:
This will validate with pretty much any online validator such as https://www.jsonschemavalidator.net/, but
php-json-schema
will throw an error saying that it was expecting anobject
but it received an array[{"animals": [ "cat", "dog", "bird" ],"cars": [ "honda", "bmw", "hyundai" ]},{"animals": [ "elephant", "giraffe", "cheetah" ],"cars": [ "mclaren", "ferrari", "alfa romeo" ]}]
.