Skip to content

Commit 69b697e

Browse files
authored
add flag/collection enum
1 parent e0a308f commit 69b697e

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

graph/GuidelinesGraph.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
Table of contents
44

55
- [Microsoft Graph REST API Guidelines](#microsoft-graph-rest-api-guidelines)
6-
- [](#)
7-
- [History](#history)
86
- [Introduction](#introduction)
97
- [Legend](#legend)
108
- [Design approach](#design-approach)
@@ -21,15 +19,6 @@ Table of contents
2119
- [Recommended API design patterns](#recommended-api-design-patterns)
2220
- [References](#references)
2321

24-
##
25-
26-
#### History
27-
28-
| Date | Notes |
29-
|-------------|-----------------------------|
30-
| 2022-Jun-14 | Edit pass for formatting, links |
31-
| 2021-Sep-28 | Using summary and patterns style |
32-
| 2020-Oct-04 | Initial version in Wiki |
3322

3423
## Introduction
3524

@@ -427,7 +416,30 @@ but it is also open for future scenarios:
427416
</EnumType>
428417
```
429418

419+
#### Flag Enums or Collection of Enums
420+
421+
In case an enum can have multiple values at the same time the tentation is to model the property as a collection of Enums:
422+
423+
```xml
424+
<Property Name="displayMethods" Type="Collection(displayMethod)"/>
425+
```
426+
427+
However, [Flagged Enums](https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html#_Toc38530378) can model this use case scenario:
428+
429+
```diff
430+
- <EnumType Name="displayMethod">
431+
+ <EnumType Name="displayMethod" isFlag="true">
432+
<Member Name="tip" Value="0" />
433+
<Member Name="unknownFutureValue" Value="1" />
434+
<Member Name="alert" Value="2" />
435+
- <Member Name="dialog" Value="3" />
436+
+ <Member Name="dialog" Value="4" />
437+
</EnumType>
438+
```
439+
440+
With such enum, customers can select multiple values in a single field:
430441

442+
`displayMethod = tip | alert`
431443

432444
## API contract and non-backward compatible changes
433445

0 commit comments

Comments
 (0)