Extending resourceTypes (types composing)


#1

In the RAML 200 tutorial it is said that I can extend resourceTypes using “types composing”. However, I am unable to find anything regarding this.

The example is as following:

resourceTypes:
  - readOnlyCollection:
      get:
        description: Get a list of <<resourcePathName>>.
        responses:
          200:
            body:
              application/json:
                example: |
                  <<exampleCollection>>
  - collection:
      get:
        description: Get a list of <<resourcePathName>>.
        responses:
          200:
            body:
              application/json:
                example: |
                  <<exampleCollection>>
      post:
        description: |
          Add a new <<resourcePathName|!singularize>> to Jukebox.
        responses:
          200:
            body:
              application/json:
                example: |
                  { "message": "The <<resourcePathName|!singularize>> has been properly entered" }

ReadOnlyCollection and Collection inherit the same functionality, so one might was well let Collection inherit from ReadOnlyCollection. Is that possible somehow?

Also, what root element should I give external files where I keep my resourceTypes? I include them in my root document using

resourceTypes:
  - collection: !include types/collectionType.raml

#2

You simply put readOnlyCollection as the type for collection:

resourceTypes:
  - readOnlyCollection:
      get:
        description: Get a list of <<resourcePathName>>.
        responses:
          200:
            body:
              application/json:
                example: |
                  <<exampleCollection>>
  - collection:
      type: readOnlyCollection
      post:
        description: |
          Add a new <<resourcePathName|!singularize>> to Jukebox.
        responses:
          200:
            body:
              application/json:
                example: |
                  { "message": "The <<resourcePathName|!singularize>> has been properly entered" }