You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[API contract and non-backward compatible changes](#api-contract-and-non-backward-compatible-changes)
@@ -26,6 +26,7 @@ Table of contents
26
26
27
27
| Date | Notes |
28
28
|-------------|-----------------------------|
29
+
| 2023-Aug-8 | New and updated patterns |
29
30
| 2022-Jun-14 | Edit pass for formatting, links |
30
31
| 2021-Sep-28 | Using summary and patterns style |
31
32
| 2020-Oct-04 | Initial version in Wiki |
@@ -159,25 +160,6 @@ In Microsoft Graph, a top-level API category might represent one of the followin
159
160
160
161
Effectively, top-level categories define a perimeter for the API surface; thus, a new category creation requires additional rigor and governance approval.
161
162
162
-
### Query support
163
-
164
-
Microsoft Graph APIs should support basic query options in conformance with OData specifications and [Microsoft REST API Guidelines for error condition responses](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
|:heavy_check_mark:**MUST** support `$select on resource` to enable properties projection. |
169
-
|:ballot_box_with_check:**SHOULD** support `/entityTypeCollection/{id}?$expand=navProp1` option for navigation properties of entities. |
170
-
|:ballot_box_with_check:**SHOULD** support `$filter` with `eq` and `ne` operations on properties of entity collections. |
171
-
|:heavy_check_mark:**MUST** support [server-driven pagination](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#981-server-driven-paging) of collections using a [nextLink](http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_ControlInformationnextLinkodatanextL). |
172
-
|:ballot_box_with_check:**SHOULD** support [client-driven pagination](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#982-client-driven-paging) of collections using `$top` and `$skip` (or `$skipToken`). |
173
-
|:ballot_box_with_check:**SHOULD** support `$count` for collections. |
174
-
|:ballot_box_with_check:**SHOULD** support sorting with `$orderby` both ascending and descending on properties of the entities. |
175
-
176
-
The query options part of an OData URL can be quite long, potentially exceeding the maximum length of URLs supported by components involved in transmitting or processing the request. One way to avoid this is to use the POST verb instead of GET with the `$query` segment, and pass the query options part of the URL in the request body as described in the chapter
Another way to avoid this is to use JSON batch as described in the [Microsoft Graph batching documentation](https://docs.microsoft.com/graph/json-batching#bypassing-url-length-limitations-with-batching).
180
-
181
163
### Resource modeling patterns
182
164
183
165
You can model structured resources for your APIs by using the OData entity type or complex type. The main difference between these types is that an entity type declares a key property to uniquely identify its objects, and a complex type does not. In Microsoft Graph, this key property is called `id` for server-created key values. If there is a natural name for the key property, then the workload can use that.
@@ -248,6 +230,26 @@ Following are a few pros and cons to decide which pattern to use:
248
230
> **Note:**
249
231
> As can be seen in a few of the pros and cons, one of the important aspects discussed here is that the API design goes beyond the syntactical aspects of the API. Therefore, it is important to plan ahead how the API evolves, lay the foundation, and allow users to form a good understanding of the semantics of the API. **Changing the semantics is always a breaking change.** The different modeling patterns differ in how they express syntax and semantics and how they allow the API to evolve without breaking compatibility. For more information, see [API contract and non-backward compatible changes](#api-contract-and-non-backward-compatible-changes) later in this article.
250
232
233
+
### Query support
234
+
235
+
Microsoft Graph APIs should support basic query options in conformance with OData specifications and [Microsoft REST API Guidelines for error condition responses](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
|:heavy_check_mark:**MUST** support `$select on resource` to enable properties projection. |
240
+
|:ballot_box_with_check:**SHOULD** support `/entityTypeCollection/{id}?$expand=navProp1` option for navigation properties of entities. |
241
+
|:ballot_box_with_check:**SHOULD** support `$filter` with `eq` and `ne` operations on properties of entity collections. |
242
+
|:heavy_check_mark:**MUST** support [server-driven pagination](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#981-server-driven-paging) of collections using a [nextLink](http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_ControlInformationnextLinkodatanextL). |
243
+
|:ballot_box_with_check:**SHOULD** support [client-driven pagination](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#982-client-driven-paging) of collections using `$top` and `$skip` (or `$skipToken`). |
244
+
|:ballot_box_with_check:**SHOULD** support `$count` for collections. |
245
+
|:ballot_box_with_check:**SHOULD** support sorting with `$orderby` both ascending and descending on properties of the entities. |
246
+
247
+
The query options part of an OData URL can be quite long, potentially exceeding the maximum length of URLs supported by components involved in transmitting or processing the request. One way to avoid this is to use the POST verb instead of GET with the `$query` segment, and pass the query options part of the URL in the request body as described in the chapter
Another way to avoid this is to use JSON batch as described in the [Microsoft Graph batching documentation](https://docs.microsoft.com/graph/json-batching#bypassing-url-length-limitations-with-batching).
251
+
252
+
251
253
### Behavior modeling
252
254
253
255
The HTTP operations dictate how your API behaves. The URL of an API, along with its request/response bodies, establishes the overall contract that developers have with your service. As an API provider, how you manage the overall request/response pattern should be one of the first implementation decisions you make.
@@ -267,6 +269,7 @@ Operation resources must have a binding parameter that matches the type of the b
267
269
268
270
For a complete list of standard HTTP operations, see the [Microsoft REST API Guidelines error condition responses](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
269
271
272
+
270
273
### Error handling
271
274
272
275
Microsoft REST API Guidelines provide guidelines that Microsoft Graph APIs should follow when returning error condition responses. You can improve API traceability and consistency by using the recommended Microsoft Graph error model and the Microsoft Graph utilities library to provide a standard implementation for your service:
@@ -388,7 +391,8 @@ The guidelines in previous sections are intentionally brief and provide a jump s
388
391
|[Namespace](./patterns/namespace.md)| Organize resource definitions into a logical set. |
389
392
|[Navigation properties](./patterns/navigation-property.md)| Model resource relationships |
390
393
|[Operations](./patterns/operations.md)| Model complex business operations |
391
-
|[Type hierarchy](./patterns/subtypes.md)| Model `is-a` relationships using subtypes. |
394
+
| [Type hierarchy](./patterns/subtypes.md) | Model `is-a` relationships using subtypes.
395
+
| [Viewpoint](./patterns/viewpoint.md) | Model user specific properties for a shared resource.
0 commit comments