0

First, this question is similar to, but different from How to define an array of a type in an external file in Raml?, except I want to make a DataType (A) that has a property that is a union of two other DataTypes B and C.

For example, here is the B RAML:

#%RAML 1.0 DataType
type: object
properties:
   some: integer

Here is the C RAML:

#%RAML 1.0 DataType
type: object
properties:
  other: string

And finally here is the problematic A RAML:

#%RAML 1.0 DataType
type: object
properties:
   union: !include B | !include C

In the solution to the aforementioned post, the A RAML would have something like:

#%RAML 1.0 DataType
    type: object
    properties:
       union: 
          type: union
          items: !include B | !include C

But that doesn't work either. Any ideas how to do this?

Thanks!

Matthew
  • 21
  • 4

1 Answers1

0

I have found the answer. It is to use Library instead of DataType fragments. You can nest library references inside library definitions.

So, you can have a Library fragment in which B is defined, another in which C is defined, and then another in which A is defined as a union of B and C. Problem solved.

Here is a link to the article that spells out libraries and fragments: https://medium.com/raml-api/raml-101-libraries-and-datatypes-fragments-1889b2e82c27

Full creds goes to an anonymous hellper inside Mulesoft that pointed me to the article. Thanks, you know who you are.

Matthew
  • 21
  • 4