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
Copy file name to clipboardExpand all lines: graph/GuidelinesGraph.md
+37-39Lines changed: 37 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Table of contents
16
16
-[Error handling](#error-handling)
17
17
-[API contract and non-backward compatible changes](#api-contract-and-non-backward-compatible-changes)
18
18
-[Versioning and deprecation](#versioning-and-deprecation)
19
-
-[Recommended API patterns](#recommended-api-patterns)
19
+
-[Recommended API design patterns](#recommended-api-design-patterns)
20
20
-[References](#references)
21
21
22
22
##
@@ -69,7 +69,7 @@ The design of your API is arguably the most important investment you will make.
69
69
70
70
An established interface contract allows developers to use your API while internal teams are still working on implementation; API specifications enable designing user experience and test cases in parallel. Starting with user-facing contracts also promotes a good understanding of system interactions, your modeling domain, and an understanding of how the service will evolve.
71
71
72
-
Microsoft Graph supports resource and query-based API styles that follow HTTP, REST, and JSON standards, where the API contract is described by using OData conventions and schema definition. For more information, see [Documentation · OData Version 4.01](https://www.odata.org/documentation/).
72
+
Microsoft Graph supports resource and query-based API styles that follow HTTP, REST, and JSON standards, where the API contract is described by using OData conventions and schema definitions. For more information, see [Documentation · OData Version 4.01](https://www.odata.org/documentation/).
73
73
74
74
In general, API design includes the following steps:
75
75
@@ -99,7 +99,7 @@ At every step of your design, you need to consider security, privacy, and compli
99
99
100
100
### Naming
101
101
102
-
API resources are typically described by nouns. Resource and property names appear in API URLs and payloads and must be descriptive and easy to understand. Ease of understanding comes from familiarity and recognition; therefore, when thinking about naming, you should favor consistency with other Microsoft Graph APIs, names in the product user interface, and industry standards. Microsoft Graph naming conventions follow the [Microsoft REST API Guidelines](https://github.com/microsoft/api-guidelines/).
102
+
API resources are typically described by nouns. Resource and property names appear in API URLs and payloads and must be descriptive and easy to understand. Ease of understanding comes from familiarity and recognition; therefore, when thinking about naming, you should favor consistency with other Microsoft Graph APIs, names in the product user interface, and industry standards. Microsoft Graph naming conventions follow the [Microsoft REST API naming guidelines)](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#17-naming-guidelines).
103
103
104
104
Following is a short summary of the most often used conventions.
105
105
@@ -132,15 +132,15 @@ A Uniform Resource Locator (URL) is how developers access the resources of your
132
132
Navigation paths to Microsoft Graph resources are generally broken into multiple segments,
-**scheme and host segments** are always [`https://graph.microsoft.com`](https://graph.microsoft.com/v1.0/users).
135
+
-`scheme` and `host` segments are always [`https://graph.microsoft.com`](https://graph.microsoft.com/v1.0/users).
136
136
137
-
-**version** can be v1.0 or beta.
137
+
-`version` can be v1.0 or beta.
138
138
139
-
-**category** segment is a logical grouping of APIs into top-level categories.
139
+
-`category` is a logical grouping of APIs into top-level categories.
140
140
141
-
-**pathSegment** is one or many navigation segments that can address an entity, collection of entities, property, or operation available for an entity.
141
+
-`pathSegment` is one or many navigation segments that can address an entity, collection of entities, property, or operation available for an entity.
142
142
143
-
-**query string** must follow the OData standard for query representations and is covered in the Query section of OData specifications.
143
+
-`query` string must follow the OData standard for query representations and is covered in the Query section of OData specifications.
144
144
145
145
While HTTP defines no constraints on how different resources are related, it does encourage the use of URL path segment hierarchies to convey relationships. In Microsoft Graph, relationships between resources are supported by the OData concepts of singletons, entitySets, entities, complex types, and navigation properties.
146
146
@@ -160,7 +160,7 @@ Effectively, top-level categories define a perimeter for the API surface; thus,
160
160
161
161
### Query support
162
162
163
-
Microsoft Graph APIs should support basic query options in conformance with OData specifications and [Microsoft REST API Guidelines](https://github.com/microsoft/api-guidelines/blob/master/Guidelines.md#7102-error-condition-responses).
163
+
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).
@@ -174,13 +174,13 @@ Microsoft Graph APIs should support basic query options in conformance with ODat
174
174
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 documentation](https://docs.microsoft.com/graph/json-batching#bypassing-url-length-limitations-with-batching).
177
+
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).
178
178
179
179
### Resource modeling patterns
180
180
181
181
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.
182
182
183
-
Because objects of complex types in Microsoft Graph don’t have unique identifiers, they are not directly addressable via URIs. Therefore, you must not use complex type to model addressable resources such as individually addressable items within a collection. For more information, see the [Microsoft REST API Guidelines](https://github.com/microsoft/api-guidelines/blob/graph/Guidelines.md#93-collection-url-patterns). Complex types are better suited to represent composite properties of API entities.
183
+
Because objects of complex types in Microsoft Graph don’t have unique identifiers, they are not directly addressable via URIs. Therefore, you must not use complex type to model addressable resources such as individually addressable items within a collection. For more information, see the [Microsoft REST API Guidelines collection URL patterns](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#93-collection-url-patterns). Complex types are better suited to represent composite properties of API entities.
184
184
185
185
```xml
186
186
<EntityTypeName="Author">
@@ -242,11 +242,11 @@ If possible, APIs SHOULD use resource-based designs with standard HTTP methods r
242
242
243
243
Operation resources must have a binding parameter that matches the type of the bound resource. In addition, both actions and functions support overloading, meaning an API definition might contain multiple actions or functions with the same name.
244
244
245
-
For a complete list of standard HTTP operations, see the [Microsoft REST API Guidelines](https://github.com/microsoft/api-guidelines/blob/master/Guidelines.md#7102-error-condition-responses).
245
+
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).
246
246
247
247
### Error handling
248
248
249
-
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:
249
+
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:
250
250
251
251
```http
252
252
{
@@ -266,45 +266,45 @@ The top-level error code must be aligned with HTTP response status codes accordi
266
266
267
267
-**Simple error**: An API wants to report an error with top-level details only. The error object contains the top-level error code, message and target (optional).
268
268
269
-
```http
270
-
{
271
-
"error": {
272
-
"code": "BadRequest",
273
-
"message": "Cannot process the request because it is malformed or incorrect.",
274
-
"target": "Resource X (Optional)"
275
-
}
276
-
}
277
-
```
269
+
```http
270
+
{
271
+
"error": {
272
+
"code": "BadRequest",
273
+
"message": "Cannot process the request because it is malformed or incorrect.",
274
+
"target": "Resource X (Optional)"
275
+
}
276
+
}
277
+
```
278
278
279
279
-**Detailed error**: An API needs to provide service-specific details of the error via the innererror property of the error object. It is intended to allow services to supply a specific error code to help differentiate errors that share the same top-level error code but are reported for different reasons.
280
-
281
-
```http
282
-
{
283
-
"error": {
284
-
"code": "BadRequest",
285
-
"message": "Cannot process the request because it is malformed or incorrect.",
286
-
"innererror": {
287
-
"code": "requiredFieldOrParameterMissing",
288
-
280
+
281
+
```http
282
+
{
283
+
"error": {
284
+
"code": "BadRequest",
285
+
"message": "Cannot process the request because it is malformed or incorrect.",
286
+
"innererror": {
287
+
"code": "requiredFieldOrParameterMissing",
288
+
289
+
}
290
+
}
289
291
}
290
-
}
291
-
}
292
-
```
292
+
```
293
293
294
294
| Microsoft Graph enforces the following error rules |
|:heavy_check_mark:**MUST** return an error property with a child code property in all error responses. |
297
297
|:heavy_check_mark:**MUST** return a 403 Forbidden error when the application or signed-in user has insufficient permissions present in the auth token. |
298
298
|:heavy_check_mark:**MUST** return a 429 Too Many Requests error when the client exceeded throttling limits, and a 503 Service Unavailable error when the service overloaded but the client is within throttling limits.|
299
-
|:ballot_box_with_check:**SHOULD** return a 404 Not Found error if a 403 would result in information disclosure. |
299
+
|:ballot_box_with_check:**SHOULD** return a 404 Not Found error if a 403 error would result in information disclosure. |
300
300
301
301
For a complete mapping of error codes to HTTP statuses, see
## API contract and non-backward compatible changes
305
305
306
306
The Microsoft Graph definition of breaking changes is based on the
307
-
[Microsoft REST API Guidelines](https://github.com/microsoft/api-guidelines/blob/graph/Guidelines.md#123-definition-of-a-breaking-change). In general, making all but additive changes to the API contract for existing elements is considered breaking. Adding new elements is allowed and not considered a breaking change.
307
+
[Microsoft REST API Guidelines definition of a breaking change](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#123-definition-of-a-breaking-change). In general, making all but additive changes to the API contract for existing elements is considered breaking. Adding new elements is allowed and not considered a breaking change.
308
308
309
309
**Non-breaking changes:**
310
310
@@ -345,12 +345,10 @@ On the beta endpoint, breaking changes and deprecation of APIs are allowed with
345
345
346
346
Detailed requirements for versioning and deprecation are described in the [Deprecation guidelines](./deprecation.md).
347
347
348
-
## Recommended API patterns
348
+
## Recommended API design patterns
349
349
350
350
The guidelines in previous sections are intentionally brief and provide a jump start for Microsoft Graph API developers. More detailed design guidance about REST APIs is published at the [Microsoft REST API Guidelines](https://github.com/microsoft/api-guidelines/). Microsoft Graph-specific patterns are outlined in the following table.
0 commit comments