Skip to content

basic support to test against official JSON-Schema-Test-Suite #122

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

Conversation

StarpTech
Copy link
Member

This PR will add basic support to test against the official https://github.com/json-schema-org/JSON-Schema-Test-Suite. It contains only tests for the required feature.

@StarpTech StarpTech requested review from mcollina and allevo October 9, 2018 20:28
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! Can you add draft 5 and draft 6?

@StarpTech
Copy link
Member Author

It should be added incrementally or what do you mean?

@mcollina
Copy link
Member

mcollina commented Oct 9, 2018

Would it be hard to just add it to this PR?

@StarpTech
Copy link
Member Author

The required test-case or all JSON files?

@StarpTech
Copy link
Member Author

I added draft 6,7 of the required test-case.

@StarpTech
Copy link
Member Author

StarpTech commented Oct 9, 2018

@mcollina one important note: I had to add explicitly the type: 'object' property to all schemas otherwise fast-json-stringify will throw undefined unsupported 😥

@StarpTech
Copy link
Member Author

Do we really need to support Node 4 ?

@mcollina
Copy link
Member

mcollina commented Oct 9, 2018

@mcollina one important note: I had to add explicitly the type: 'object' property to all schemas otherwise fast-json-stringify will throw undefined unsupported 😥 acccording to the spec it should fallback to type object when properties is used.

We should actually behave properly and assume the same, it shouldn't be hard to patch.

Do we really need to support Node 4 ?

We can bump the major without much problems if it's just for the support.

@StarpTech
Copy link
Member Author

We should actually behave properly and assume the same, it shouldn't be hard to patch.

I think it is very hard because we have to handle the any type-case which will make optimizations very complicated. In my opinion it's fine to set some prerequisites in order to build an optimized stringify function this includes to always add the type in your schemas.

e.g

schema

{
    "properties": {
        "foo": {},
        "bar": {}
    },
    "required": ["foo"]
}

this is valid:

{"foo": 1}

json-schema/json-schema#172

@StarpTech
Copy link
Member Author

We can bump the major without much problems if it's just for the support.

Great, I will remove node 4 from the matrix.

@StarpTech
Copy link
Member Author

Please check again I infer type based on the validation keywords.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, this is fantastic. I've just left a couple of nits.

.travis.yml Outdated
@@ -1,7 +1,6 @@
language: node_js
sudo: false
node_js:
- '4'
- '6'
- '8'
- '9'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you drop 9 as well?

'exclusiveMaximum',
'minimum',
'exclusiveMinimum'
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just use const for these.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina mcollina requested a review from delvedor October 11, 2018 18:56
Copy link
Member

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@StarpTech StarpTech merged commit 1326056 into fastify:master Oct 12, 2018
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

Successfully merging this pull request may close these issues.

3 participants