Skip to content

Commit cf8c460

Browse files
committed
Add guidelines for polymorphism
1 parent f898f22 commit cf8c460

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

azure/Guidelines.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,12 @@ This indicates to client libraries and customers that values of the enumeration
492492
<a name="json-document-extensible-enums"></a>
493493
:white_check_mark: **DO** document to customers that new values may appear in the future so that customers write their code today expecting these new values tomorrow.
494494

495+
<a name="json-return-extensible-enum-value"></a>
496+
:heavy_check_mark: **YOU MAY** return a value for an extensible enum that is not one of the values defined for the api-version specified in the request.
497+
498+
<a name="json-accept-extensible-enum-value"></a>
499+
:warning: **YOU SHOULD NOT** accept a value for an extensible enum that is not one of the values defined for the api-version specified in the request.
500+
495501
<a name="json-removing-enum-value-is-breaking"></a>
496502
:no_entry: **DO NOT** remove values from your enumeration list as this breaks customer code.
497503

@@ -540,6 +546,18 @@ Below is an example of JSON for a Rectangle and Circle:
540546
```
541547
Both Rectangle and Circle have common fields: `kind`, `fillColor`, `lineColor`, and `subscription`. A Rectangle also has `x`, `y`, `width`, and `length` while a Circle has `x`, `y`, and `radius`. The `subscription` is a nested polymorphic type. A `free` subscription has no additional fields and a `paid` subscription has `expiration` and `invoice` fields.
542548

549+
<a name="json-polymorphism-kind-extensible"></a>
550+
:ballot_box_with_check: **YOU SHOULD** define the kind field of a polymorphic type to be an extensible enum.
551+
552+
<a name="json-polymorphism-kind-immutable"></a>
553+
:warning: **YOU SHOULD NOT** allow an update (patch) to change the kind field of a polymorphic type.
554+
555+
<a name="json-polymorphism-versioning"></a>
556+
:warning: **YOU SHOULD NOT** return properties of a polymorphic type that are not defined for the api-version specified in the request.
557+
558+
<a name="json-polymorphism-arrays"></a>
559+
:warning: **YOU SHOULD NOT** specify a polymorphic type as the type of an array property.
560+
543561
## Common API Patterns
544562

545563
<a name="actions"></a>

0 commit comments

Comments
 (0)