apiaryio / gavel-spec

Behavior specification for Gavel, validator of HTTP transactions
http://www.relishapp.com/apiary/gavel/
MIT License
105 stars 11 forks source link

Does gavel have patternProperties support? #2

Closed richleland closed 11 years ago

richleland commented 11 years ago

I'm using Dredd to run our documentation through CI and came across the following...

One of my resources returns datetimes as keys that I need to validate:

{
  "data": {
    "2013-10-14T09:00": {
      ...
    }
  }
}

I tried adding the following to the Schema section of my API blueprint doc, which allows Dredd/gavel to run, but not actually validate:

{
  "type": "object",
  "required": true,
  "properties": {
    "data": {
      "type": "object",
      "required": true,
      "patternProperties": {
        "^[0-9]{4}-[0-9]{2}-[0-9]{2}$": {
          "type": "object",
          "required": true,
          ...
        }
      }
    }
  }
}

I noticed that the JSON Schema spec defines a patternProperties that allows you to use a regex:

"patternProperties": {
  "^(/[^/]+)+$": {}
},

Does gavel support patternProperties? I ack'd the code and didn't see it. Happy to contribute, but just wanted to make sure gavel doesn't already handle this type of validation in some other way.

netmilk commented 11 years ago

Hi,

Gavel is using Amanda validator and its JSON Schema implementation. Amanda should support complete feature set from draft v3, I guess. Have a look at this Amanda doc: https://github.com/Baggz/Amanda/blob/master/docs/json/comparison.md

If you will face any other issue with Gavel or Dredd, I'm happy to help.

Adam