Open jpettit opened 6 years ago
@ehmicky - any reservation to upgrading to 6?
I think that's a great idea. We can actually even go to JSON schema v7.
What works:
ajv
, the library we use for validating the HTTP response with JSON schema, supports v7What does not work:
test-openapi
). JSON schema v4 is not forward compatible with v6/v7. For example exclusiveMaximum
goes from being a boolean to being an integer. So we would need to convert JSON schema v4 to v7. $$random
template helper and the HTTP request random generation based on JSON schema use json-schema-faker
. Unfortunately they only support JSON schema v4 at the moment. I've opened many issues but it seems like v6/v7 support is hard and going to take a long time. The plan could be to allow JSON schema v7 in $$random
but to convert it down to JSON schema v4.For the v4 to v7 and v7 to v4 conversions, I am unfortunately not aware any library currently does that (if you do, please let me know!), which probably means creating that first. I actually am quite familiar with JSON schema (I went through the spec many times) and I have a list of all the conversions required, but this needs to be implemented and unit tested. That's the main issue.
By the way most JSON schema v7 can be expressed in JSON schema v4 (although much more verbosely). For example:
const: "foobar"
-> enum: ["foobar"]
if
, then
, else
-> oneOf
+ allOf
+ not
contains: value
-> { not: { items: { not: value } } }
Actually the only JSON schema v7 property that (I think) cannot be converted to v4 is propertyNames
.
Specifying a
const
value is only supported in json-schema 6. Updating the schema draft enables validation of the following response body like so in a task: