1) When writing RAML, can I use nesting in my schema definition?
For example:
schemas:
- DNSResponse: |
{
\"type\": \"object\",
\
I think the following example applies here. It demonstrates defining two types Url
and File
(using RAML 1.0) and then using the logical OR to allow either type (aka schema) in Item
as a subschema. You could potentially include more types if needed.
I also defined some examples inline which demonstrate how it works if you are using the raml-parser.
#%RAML 1.0
types:
Url:
properties:
url:
type: string
example: http://www.cats.com/kittens.jpg
description: |
The url to ingest.
File:
properties:
filename:
type: string
example: kittens.jpg
description: |
Name of the file that will be uploaded.
Item:
description: |
An example of a allowing multiple types using RAML 1.0
properties:
ext:
type: File | Url
examples:
file_example:
content:
ext:
filename: video.mp4
url_example:
content:
ext:
url: http://heres.a.url.com/asset.jpg
should_fail:
content:
ext:
unexpected: blah