JSON Schemas in RAML 1.0


#1

I’m helping out with development on ramlfications, a Python library for processing RAML specifications. We’d like to understand better how JSON Schemas can be used in RAML.

When defining a type, we understand the simple case of referencing an external JSON Schema document:

types:
    Person:
        type: !include person.json

What’s less obvious is whether we can include a JSON Schema document inline:

types:
    Person:
        type: |
            {"$schema": "http://json-schema.org/draft-03/schema",
             "properties": {
                 "input": {
                     "required": false,
                     "type": "string"
                 }
             },
             "required": false,
             "type": "object"
           }

Should this be considered legal?


#2

Yes, it’s considered valid @fdrake! This is because of the !include mechanism that basically appends any content from the file you pointing to, to the node you used the !include tag.


#3

You guys can also take a look at https://github.com/raml-org/raml-tck/tree/wip/2.0.0 with 142 tests around the RAML specs. I constantly add more and it’s by far not finished yet, but at least it gives you some possibilities to test the parser :slight_smile: I have sent it to Lynn also. She should be aware!


#4

I actually added your example here.


#5

If you’d like to contribute more, please go ahead. The syntax for tests are quite simple :slight_smile:


#6

Thanks, Christian! I’ll take a look at your tests.

It looks like there are only positive tests; do you have any plans to include negative tests as well (where validation of the RAML is expected to fail)?


#7

Never mind; I see how you’ve included negative tests.