phpunit-json-assertions
phpunit-json-assertions copied to clipboard
"const" keyword not working
We use the test folder in the repository to test our jsonSchema. We have created a class based on the same structure as AssertTaitTest.php.
But when we want to test our json the keyword const doesn't work despite the errors put in the schema on purpose. However, the keyword enum works and is well taken into account in the errors.
You can find attached our test json and the associated schema.
Thanks in advance!
Our jsonSchema:
{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://<ourwebsite.fr/Schemas/ApiComponent/OuvragePush", "title": "Api Component Schema: Ouvrage Push", "type": "object", "properties": { "type": { "type": "string", "const": "OuvragePush"}, "price": { "type": "string", "const": "United States of America" } }, "required": [ "type", "price" ] }
Our mock json data:
'{ "type":"OuvragePushooo", "price": "14" }'
I don't believe const is supported. This library uses https://github.com/justinrainbow/json-schema under the hood which claims to support draft-3 and draft-4. Const was added in draft-6.
Thank you very much for the answer!