Skip to content

"const" keyword not working #56

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

Open
SchMatthieu opened this issue Feb 10, 2023 · 2 comments
Open

"const" keyword not working #56

SchMatthieu opened this issue Feb 10, 2023 · 2 comments

Comments

@SchMatthieu
Copy link

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" }'

@J-T-McC
Copy link
Contributor

J-T-McC commented Feb 10, 2023

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.

@SchMatthieu
Copy link
Author

Thank you very much for the answer!

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

2 participants