Mocking service: don't forget the !include before the schema name


#1

No answer needed, please disregard, found my mistake.

My RAML file was missing the !include before the schema name.

If anyone sees a similar error, check your RAML file and verify that the !include is there.

A schema that seems to work fine when I test it on the JSON Validate site throws an error with my mocking service.

The error I get with a POST to my API with mocking service on is:

400

{
    "error": "schema did not parse: Unexpected token e"
}

test-schema.schema

{
  "$schema": "http://json-schema.org/draft-03/schema#",
  "type": "object",
  "properties": 
  {
    "test-thing":
    {
      "type": "object",
      "properties":
      {
        "thing_type": 
        {
          "type":"integer",
          "required":true
          },
        "is_a_thing": 
        {
          "type":"boolean",
          "required":false
          },
        "designator": 
        {
          "type":"string",
          "required":false
          },
        "name": 
        {
          "type":"string",
          "required":false
        }
      } 
    } 
  }
}

valid object

On the JSON Validate site, this object validates with the above schema, but on API Designer, it throws the 400 error.

{
  "test-thing": {
    "thing_type": 1,
    "is_a_thing": true,
    "designator": "Experimental",
    "name": "foo_test_thing"
  }
}

invalid object

On JSON Validate, this correctly fails with:

Invalid: invalid type: string (expected integer)
JSON Schema element: /properties/test-thing/properties/thing_type/type
JSON Content path: /test-thing/thing_type

{
  "test-thing": {
    "thing_type": "oh no",
    "is_a_thing": 555,
    "designator": false,
    "name": "foo_test_thing"
  }
}

#2

hi,
I am still encountered with same issue "“schema did not parse: Unexpected token e”,
despite of correctly including the schema using !include as mentioned here.

Appreciate any further help here.


#3

Still problems? Confused :smiley: