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

Commit

Permalink
Adding declaration of unions outside type expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniogarrote committed Jul 27, 2016
1 parent 8647339 commit 9747073
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions versions/raml-10/raml-10.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9747073

Please sign in to comment.