emanualjade / test-openapi

Automatic API integration testing
MIT License
14 stars 4 forks source link

Enable ajv version 6 with json schema draft-06 support #6

Open jpettit opened 6 years ago

jpettit commented 6 years ago

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:

# example json data: 
# { "field": "foobar" }

# task yml
...
  validate:
    status: 200
    body:
      properties:
        field:
          const: "foobar"
jpettit commented 6 years ago

@ehmicky - any reservation to upgrading to 6?

ehmicky commented 6 years ago

I think that's a great idea. We can actually even go to JSON schema v7.

What works:

What does not work:

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:

Actually the only JSON schema v7 property that (I think) cannot be converted to v4 is propertyNames.