Reference property of an included datatype


#1

I have created 4 datatype files and a property in one of them is a queryParameter in the main api.raml file. I have included the required file in types:

What I can not seem to find is the syntax to properly reference the property in the included Here is the type list at the top of the ami.raml file:

types:
Class: !include datatypes/Class.raml
Course: !include datatypes/Course.raml
PublishedInstructor: !include datatypes/PublishedInstructor.raml
Meeting: !include datatypes/Meeting.raml


Here is the query section as is:

queryParameters: 
  catalogSchool:
    type: string
    enum: [ art, fas, gsas, gsd, hbsd, hbsm, hcol, hds, hgse, hks, hls, hms, hsdm, hsph, dce ]
    required: false   

While the above works just fine, I want to externalize the catalogSchool which is in the Class.raml file. The reason is that catalogSchool may change and this will save others having to figure out changes each time.

How would I properly reference catalogSchool as a queryParameter in this api.raml file? catalogSchool: does not work the type from the Class.raml file is not picked up.

Thanks


#2

class.raml would be:

#%RAML 1.0 Library

types:
  catalogSchool:
    type: string
    enum: [ art, fas, gsas, gsd, hbsd, hbsm, hcol, hds, hgse, hks, hls, hms, hsdm, hsph, dce ]

ami.raml would have:

uses:
  class: class.raml

and in the query section:

  queryParameters: 
    catalogSchool:
      type: class.catalogSchool
      required: false

#3

Thank you very much for the reply. I look forward to taking it for a test drive. I must have a setting wrong since I just got this notice - apparently 7 days after your post. Thank you again.


#4

I have a follow up. I have implemented your suggestion, and it works. I was wondering why this is a class rather than a datatype. In other words why not put this with the other datatypes?
Thanks.


#5

I copied the word “class” because you used it in your example:

Class: !include datatypes/Class.raml

You can call it whatever you want. I suggest you read the RAML specification regarding libraries.

Regards