Replies: 5 comments 1 reply
-
All very valid points and workflows I didn't think about and we can do all of them. Expect to see PRs linking into this soon incrementally implementing various of these ideas. Note that it is already possible to add comments (as the tool will ignore them), though maybe worth using |
Beta Was this translation helpful? Give feedback.
-
I'm explicitly testing for and documenting |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I wanted to avoid adding a new keyword for testing subschemas, and came up with an alternative that is equally flexible and simple IMHO: letting So in your example above, you can set: {
....
"target": "https://www.krakend.io/schema/v2.7/modifier/martian.json#/header.Modifier"
....
} |
Beta Was this translation helpful? Give feedback.
-
I'm also implementing your |
Beta Was this translation helpful? Give feedback.
-
This proposal is for:
In the current implementation, the
test
command requires you to write a JSON file with the following fields:description
schema
tests
An array with test objects:description
data
valid
This format is functional and allows us to perform testing. Yet, tests might be unnecessarily verbose, as on one side, you declare all descriptions, and on the other, you might repeat yourself over and over in the
data
field.Here is a fictional example of a test using this proposal:
It introduces the following changes:
$schema
: Because we should add to all tests the schema that validates this test suite, and this schema should be public as part of the JSON schema spec. E.g.:http://json-schema.org/draft-07/tests-schema#
target
: Formerlyschema
. Any other keyword would be fine, but I would avoid using$schema
andschema
simultaneouslyref_data
: It could be useful to pre-generate (massive) data in a separate process, reuse it, and inject it into tests. A problem I see with the current system, is that you can repeat a large content in thedata
section multiple times to complete a basic functional test. It is easy to end-up with a test case of 500 lines to test properly a modest schema.@comment
: I have added a keyword to add comments (not the same as descriptions) to the testssubschema
: This would open the door that a test case takes the responsibility of a single property. Just like a unit test can take responsibility of a function. Any JSON Schema out there is going to define multiple properties, many of which are mandatory. Why would you declare all this unnecessarydata
every time to test a part where the parent properties are not involved? It would be nice to test them one by one separately.This is a draft of the JSON Schema that would validate this test suite:
This is just an idea, looking forward to hear thoughts
Beta Was this translation helpful? Give feedback.
All reactions