# @union tag in request or response

**URL:** <https://forum.opencyphal.org/t/union-tag-in-request-or-response/329>\
**Category:** Applications & Usage\
**Created:** [January 17, 2019, 9:49am UTC](https://forum.opencyphal.org/t/union-tag-in-request-or-response/329 "2019-01-17T09:49:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deekay](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@deekay](https://forum.opencyphal.org/u/deekay)\
**Post date:** [January 17, 2019, 9:49am UTC](https://forum.opencyphal.org/t/union-tag-in-request-or-response/329/1 "2019-01-17T09:49:50Z")

</div>

Hi!

Perhaps I have misunderstood the DSDL spec, but are the below DSDL examples correct?

Example1. Request contains code and a union of type1\_value/type2\_value

```auto
# Service SetMyTypeValue
# Request
uint8 code
@union
MyType1 type1_value
MyType2 type2_value
 
---
 
#Response
MyResponseCode code

```

Or

Example2. Response contains code and a union of type1\_value/type2\_value

```auto
# Service GetMyTypeValue
# Request
uint8 code

---
 
#Response
MyResponseCode code
@union
MyType1 type1_value
MyType2 type2_value

```

When compiled, I noticed that all members in request (example 1) and response (example 2) becomes part of the union. Am I correct?

Do I have to put the unions in its own type?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [January 17, 2019, 2:43pm UTC](https://forum.opencyphal.org/t/union-tag-in-request-or-response/329/2 "2019-01-17T14:43:42Z")

</div>

> When compiled, I noticed that all members in request (example 1) and response (example 2) becomes part of the union. Am I correct?

Yes.

> Do I have to put the unions in its own type?

Yes.

---

<div class="post-metadata">

**Author:** ![deekay](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@deekay](https://forum.opencyphal.org/u/deekay)\
**Post date:** [January 17, 2019, 6:55pm UTC](https://forum.opencyphal.org/t/union-tag-in-request-or-response/329/3 "2019-01-17T18:55:27Z")

</div>

As I thought =) Thanks.
