Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchemaStorage::addSchema() should call BaseConsstraint::arrayToObjectRecursive() on the provide schemas #408

Closed
shtrom opened this issue Apr 5, 2017 · 3 comments

Comments

@shtrom
Copy link

shtrom commented Apr 5, 2017

Without doing this, it might accept Array input from the caller without complaining, but the validation against those schemas will fail later with

get_object_vars() expects parameter 1 to be object, array given

at https://github.com/justinrainbow/json-schema/blob/6.0.0-dev/src/JsonSchema/SchemaStorage.php#L118

Calling BaseConsstraint::arrayToObjectRecursive() in addSchema before https://github.com/justinrainbow/json-schema/blob/6.0.0-dev/src/JsonSchema/SchemaStorage.php#L61, as Validator::validate() does https://github.com/justinrainbow/json-schema/blob/6.0.0-dev/src/JsonSchema/Validator.php#L49-L51 should solve the problem, and make handling it in Validator::validate() unecessary.

@erayd
Copy link
Contributor

erayd commented Apr 5, 2017

Thanks for reporting this.

Your suggested fix causes failed unit tests - I will need to investigate this in more detail to work out what's going on.

erayd added a commit to erayd/json-schema that referenced this issue Apr 5, 2017
@erayd
Copy link
Contributor

erayd commented Apr 5, 2017

Fixed in #409. This will be backported to 5.x.x after merge.

bighappyface pushed a commit that referenced this issue May 5, 2017
* Cast root to object

* Use function_exists to allow polyfill compatibility

* Move array->object conversion to SchemaConstraint & SchemaStorage

Fixes issue #408
erayd added a commit to erayd/json-schema that referenced this issue May 5, 2017
* Cast root to object

* Use function_exists to allow polyfill compatibility

* Move array->object conversion to SchemaConstraint & SchemaStorage

Fixes issue jsonrainbow#408
bighappyface pushed a commit that referenced this issue May 16, 2017
* Split $objectDefinition into $schema and $properties (#411)

Object validation attempts to use a single variable to store both the
object definition, and its properties. This causes validation to be
incomplete where "properties" is not set, but "additionalProperties" is.

This commit fixes both bugs in issue #353.

* Issue-414: Allow The Option of T or space for Date time. (#415)

* Testcase for minProperties with properties defined (#416)

+ Fix Test

* Tweak phpdocumentor dependency to avoid install conflicts (#421)

* [BUGFIX] Cast empty schema arrays to object (#409)

* Cast root to object

* Use function_exists to allow polyfill compatibility

* Move array->object conversion to SchemaConstraint & SchemaStorage

Fixes issue #408

* fix bug when applying defaults for array items when the schema is for (#405)

all items and add support for minItems when applying defaults

* [BUGFIX] Split "uri" format into "uri" & "uri-reference", fix meta-schema bug (#419)

* Split "uri" format into "uri" and "uri-reference"

* Correct format for id & $ref in draft-03/04 meta-schemas

See json-schema-org/JSON-Schema-Test-Suite#177 (comment)
@DannyvdSluijs
Copy link
Collaborator

This is already part of the v6.0.0. release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants