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

Commit feb4c05

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

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

versions/raml-10/raml-10.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ The RAML type system defines the following built-in types:
550550
* [any](#the-any-type)
551551
* [object](#object-type)
552552
* [array](#array-type)
553-
* [union](#union-type) via type expression
553+
* [union](#union-type)
554554
* one of the following [scalar types](#scalar-types): number, boolean, string, date-only, time-only, datetime-only, datetime, file, integer, or null
555555
556556
Additional to the built-in types, the RAML type system also allows to define [JSON or XML schema](#using-xml-and-json-schema).
@@ -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. At least 2 elements. |
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)