kbase / relation_engine

Repository containing the KBase Relation Engine API, specs, and other related files.
MIT License
3 stars 11 forks source link

Default validation fails when it encounters a $ref #29

Open ialarmedalien opened 4 years ago

ialarmedalien commented 4 years ago

Stored queries do not currently fill in the default values if they are not supplied as part of the params. Make it so!

ETA: This ticket was originally concerned with populating defaults, but further investigation revealed that the current mechanism for adding defaults (taken from the python-jsonschema repo) does not fetch $refs, so defaults do not get set in some cases.

jayrbolton commented 4 years ago

Wait really? But we that customization here: https://github.com/kbase/relation_engine/blob/develop/relation_engine_server/utils/json_validation.py#L26 And you have tests for it here: https://github.com/kbase/relation_engine/blob/develop/relation_engine_server/test/test_json_validation.py#L144

ialarmedalien commented 4 years ago

I was looking to add default values for array properties, but it doesn't look like the python jsonschema supports it. I have a couple more things to try, but if the json schema doesn't allow it, I'll close this issue.

ialarmedalien commented 4 years ago

OK, it looks like this is an issue with the way defaults are set, as the validator just blindly checks the subschema to see if there's a default field without first checking whether the subschema is a reference or not. 😖 I have changed the schemas I'm using to avoid the problem but ideally the code could be changed to fix the problem.