nidi3 / raml-tester

Test if a request/response matches a given raml definition
Apache License 2.0
71 stars 14 forks source link

No check for non-existing properties in schemas or responses #26

Closed ghost closed 9 years ago

ghost commented 9 years ago

Properties in responses that are missing in the raml-schemas does not result in errors in the RamlReport. Example response:

{
"id": 9706
"name": "Bob"
}

With raml:

          schema: |
              {
                  "properties": {
                      "id": {
                          "type": "integer"
                      }
                  },
                  "type": "object"
              }

Should result in a validation error I think.

Also, properties in schemas which does not exist in the response are validated as OK. Example response:

{
"id": 9706
}

Example raml:

    responses:
      200:
        body:
          schema: |
              {
                  "properties": {
                      "name": {
                          "type": "string"
                      },
                      "id": {
                          "type": "integer"
                      }
                  },
                  "type": "object"
              }
nidi3 commented 9 years ago

These are JSON schema issues. To get the desired result, add

additionalProperties:false required:["name","id"]

see http://spacetelescope.github.io/understanding-json-schema/reference/object.html