Include external traits issue


#1

Hi
I’ve been playing a bit with including external traits into my api spec.
According to raml spec https://github.com/raml-org/raml-spec/blob/master/07_resource_types_and_traits.md
There is no strict limit to include external ‘anonymous’ trait.

Let me explain this briefly…
Assuming I have separate trait file
xxxx.yaml

   queryParameters:
  sort:
    type: string

yyyy.yaml

  queryParameters:
      filter:
        type: string

I can add in my raml traits section

 traits:
 - foo: !include xxxx.yaml
 - bar: !include yyyy.yaml

I can also mix them with inline traits -so far so good.
But if change so the yaml file contains whole trait body

xxxx.yaml

 - xxxx:
    queryParameters:
      sort:
        type: string

yyyy.yaml

- yyyy:
      queryParameters:
          filter:
            type: string

It looks like combining them both

 traits:
 -  !include xxxx.yaml
 -  !include yyyy.yaml

simply does not work

Regards Mariusz.


#2

After further investigation i got it working like this (with multiple traits included)

  • the yaml file containing trait must not conatin leading ‘-’

    limited :
    queryParameters :
    fields :
    type : string

  • the raml file embracing this trait(s) must include them with preceeding ‘-’

    traits:       
        - !include limited.yaml  
        - !include limited2.yaml 
    

Any other case when we include ‘-’ into trait yaml simply does not work if we have more traits (more than 1) included.

Regards M.


#3

what RAML version you used ?


#4

This was version 0.8 as far as I remember. Anyway it is not my concern anymore.