API Designer "schema is not valid JSON error" - SOLVED


#1

Hi,
I am using API designer (the cloud version) to create a raml that utilizes json schemas along with the “schemas” keyword.
Here’s the raml doc that I want (i’ve removed the boilerplate top lines for brevity)

schemas:
  - Device: !include d.json
    Link: !include link.json
/d:
  get:
    responses:
      200:
        body:
          application/json:
          schema: Link
          example: |
            {
              "some-json": "example-here"
            }

I’ve already uploaded/saved the included json files in API Designer. However with this, i’m getting the following error message at the last line

"schema is not valid JSON error: Unknown character '}', expecting a string for key statement"

If I remove the “schemas” section from the top and then include the json file directly in the “schema” element, that error goes away

schema: !include link.json

I’m not sure what is it that i’m doing wrong. Any suggestion/help is appreciated.


#2

Can you post the schema, please. I copied and pasted the same RAML with an example schema I had and it is working.


#3

Ahh, the culprit was the schema. I ran the json schema thru the validator and found an extra ","
PEBCAK moment. Thanks for your help though. It led me to revalidate my schema.


#4

Ahh … This sometimes happens when you run some invalid Json or schema … The error schema is not valid JSON error: Unknown character '}', expecting a string for key statement clearly shows the schema is invalid :frowning: … It’a always a good practice to validate the Json or the schema with a validator before using and there are several online validator available like : - http://www.jsonschemavalidator.net/