From 97470733a9a3751da768696da3b93c342f29ea74 Mon Sep 17 00:00:00 2001 From: Antonio Garrote Date: Wed, 27 Jul 2016 17:10:21 +0100 Subject: [PATCH] Adding declaration of unions outside type expressions --- versions/raml-10/raml-10.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/versions/raml-10/raml-10.md b/versions/raml-10/raml-10.md index 16c5cb58..8f96127f 100644 --- a/versions/raml-10/raml-10.md +++ b/versions/raml-10/raml-10.md @@ -1083,7 +1083,12 @@ Declaring the type of a property to be `null` represents the lack of a value in #### Union Type -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: +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: + +| Facet | Descriptions | +|:------|:-------------| +| anyOf | array with the super types of the union. It cannot be empty. | + ```yaml #%RAML 1.0 @@ -1115,8 +1120,9 @@ The following example defines two types and a third type which is a union of tho ```yaml types: - CatOrDog: - type: Cat | Dog # elements: Cat or Dog + CatOrDog: # equivalent to type: Cat | Dog + type: union + anyOf: [ Cat, Dog ] Cat: type: object properties: