Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit 9747073

Browse files
Adding declaration of unions outside type expressions
1 parent 8647339 commit 9747073

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

versions/raml-10/raml-10.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,12 @@ Declaring the type of a property to be `null` represents the lack of a value in
10831083

10841084
#### Union Type
10851085

1086-
A union type is used to allow instances of data to be described by any of several types. A union type is declared via a type expression that combines 2 or more types delimited by pipe (`|`) symbols; these combined types are referred to as the union type's super types. In the following example, instances of the `Device` type may be described by either the `Phone` type or the `Notebook` type:
1086+
A union type is used to allow instances of data to be described by any of several types. A union type is declared via a type expression that combines 2 or more types delimited by pipe (`|`) symbols; these combined types are referred to as the union type's super types. Union types can also be declared using a combination of the `type` facet with value `union` and a facet `anyOf` with a value containing an array of all the union super types. In the following example, instances of the `Device` type may be described by either the `Phone` type or the `Notebook` type:
1087+
1088+
| Facet | Descriptions |
1089+
|:------|:-------------|
1090+
| anyOf | array with the super types of the union. It cannot be empty. |
1091+
10871092

10881093
```yaml
10891094
#%RAML 1.0
@@ -1115,8 +1120,9 @@ The following example defines two types and a third type which is a union of tho
11151120

11161121
```yaml
11171122
types:
1118-
CatOrDog:
1119-
type: Cat | Dog # elements: Cat or Dog
1123+
CatOrDog: # equivalent to type: Cat | Dog
1124+
type: union
1125+
anyOf: [ Cat, Dog ]
11201126
Cat:
11211127
type: object
11221128
properties:

0 commit comments

Comments
 (0)