RAML 1.0 Types Refrencing


#1

Couldn’t find my question answered, so asking here.

say I have the following in my raml:

types:
  StoryboardType: !include types/storyboard.raml
  ChapterType: !include types/chapter.raml

with types/storyboard.raml being

#%RAML 1.0 ObjectTypeDeclaration
type: object
properties:
  ...
  chapters:
    type: ChapterType[]
    required: false
  ...

How would I correctly reference “ChapterType” in the storyboard.raml to avoid Api-Workbench highlighting it as an unresolved resource inside storyboard.raml?

Thanks in advance.


#2

Hi,

Let’s see what we’ve got here. You have two different files that describe a specific type; one describes a chapter object and the other a storyboard that includes chapters. Lets start with the chapter.raml file:

#%RAML 1.0 DataType

type: object
properties:
  title: string

And last but not least the storyboard type in storyboard.raml that includes the type defined in chapter.raml:

#%RAML 1.0 DataType

type: object
properties:
  name: string
  chapters:
    type: array
    items: !include chapter.raml
    required: false

Does that answer your question?


#3

Thanks, I’ll give that a try.

EDIT:
Thanks very much, that did the trick.


#4

@christian_vogel How can I reference another Data Type as part of base type definition?

Following doesn’t seem to work in api-workbench:

#%RAML 1.0 DataType
# chapter-with-picture
type: !include chapter.raml
properties:
  image: sting