Skip to content

Commit 170a899

Browse files
committed
fix namespace guidance:
-require alias, as per [ADR-030](https://microsoft.sharepoint.com/teams/APICouncil/_layouts/OneNote.aspx?id=%2Fteams%2FAPICouncil%2FSiteAssets%2FAPI%20Council%20Notebook&wd=target%28ADRs.one%7CCC35B798-B670-4554-9FCF-1682729EFA23%2FADR-030%20Namespace%20Aliases%7C363534F8-EFBD-4201-9F11-DB02AD5B7FAA%2F%29) -support multiple levels below microsoft.graph (as per [ADR-030]) -clarify uniqueness across namespaces -clarify that any change to a custom namespace name is breaking -add alias to the examples as per above
1 parent 36e6d85 commit 170a899

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

graph/patterns/namespace.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,39 @@ API designers can use the namespace attribute of the CSDL schema to declare a
1616
namespace and logically organize related API entities in the Microsoft Graph metadata.
1717

1818
```XML
19-
<Schema Namespace="microsoft.graph.{namespace}">
19+
<Schema Namespace="microsoft.graph.{namespace}" Alias="{namespace}">
2020
...
2121
</Schema>
2222
```
2323

2424
A public namespace must contain the `microsoft.graph.` prefix and be presented in camel
25-
case; that is, `microsoft.graph.myNamespace`.
25+
case; that is, `microsoft.graph.myNamespace`. Elements defined in namespaces not prefixed
26+
with `microsoft.graph` will be mapped to the public `microsoft.graph` namespace.
27+
28+
Namespaces should not include more than two segments following the `microsoft.graph` prefix;
29+
that is, `microsoft.graph.myNamespace.mySubNamespace`.
30+
31+
Public namespaces must define an alias, and that alias must be the concatenation of
32+
the segments following the `microsoft.graph` prefix with proper camel casing rules applied;
33+
that is, `myNamespaceMySubNamespace`.
2634

2735
When type casting is required in the API query, request, or response, a fully
28-
qualified type name is represented as concatenation of a namespace and a type
29-
name. For a consistent user experience, namespaces MUST be aligned with the corresponding API category path segment.
36+
qualified type name is represented as concatenation of the namespace or alias,
37+
followed by a dot (`.`) and the type name.
3038

3139
## When to use this pattern
3240

3341
API resource grouping creates a user-friendly experience, keeping all resources for a specific feature close together and limiting the length of IDE prompts such as auto-complete in some programming languages.
3442

35-
We recommend that a new namespace be aligned with a top-level API category.
43+
For a consistent user experience, new namespace should be aligned with a top-level API category.
3644

3745
## Issues and considerations
3846

39-
- Microsoft Graph consistency requirements discourage using the same type names for different concepts even within different namespaces. Microsoft Graph type names must be descriptive and unique within the API surface without requiring full qualification.
47+
- Microsoft Graph consistency requirements discourage using the same type names for different concepts even within different namespaces. Microsoft Graph type names must be descriptive and should represent a single concept across the API Surface.
4048

4149
- A namespace must be consistent with an API category in the navigation path according to [Microsoft Graph REST API Guidelines](../GuidelinesGraph.md#uniform-resource-locators-urls).
4250

43-
- When type name is ambiguous and requires a namespace qualifier, changing a namespace is a breaking change.
51+
- Changing a namespace prefixed with `microsoft.graph`, or moving types between, into, or out of a namespace prefixed with `microsoft.graph`, is a breaking change.
4452

4553
- To extend a type in a different schema, a service must declare that schema and the type in it. This is conceptually similar to .NET partial types.
4654

@@ -51,17 +59,19 @@ We recommend that a new namespace be aligned with a top-level API category.
5159
- Microsoft Graph has some predefined constraints for declared namespaces:
5260

5361
- All public namespaces must have the prefix `microsoft.graph`.
62+
63+
- Public namespaces must declare an alias that is the concatenation of the segments following the `microsoft.graph` prefix.
64+
65+
- At most, two levels of nesting below `microsoft.graph` is recommended.
5466

55-
- Only one level of nesting deeper than `microsoft.graph` is supported.
56-
57-
- If a namespace does not begin with the `microsoft.graph` prefix, all types in the schema are coerced into the main `microsoft.graph` namespace.
67+
- If a namespace does not begin with the `microsoft.graph` prefix, all types in the schema are mapped into the public `microsoft.graph` namespace.
5868

5969
## Examples
6070

6171
### Namespace and type declarations
6272

6373
```XML
64-
<Schema Namespace="microsoft.graph.search" xmlns=”<http://docs.oasis-open.org/odata/ns/edm>”\>
74+
<Schema Namespace="microsoft.graph.search" Alias="search" xmlns=”<http://docs.oasis-open.org/odata/ns/edm>”\>
6575
6676
<EntityType Name="bookmark"
6777
</EntityType>
@@ -88,7 +98,7 @@ declarations) to match this example.
8898
<?xml version="1.0" encoding="utf-8"?>
8999
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:odata="http://schemas.microsoft.com/oDataCapabilities">
90100
<edmx:DataServices>
91-
<Schema Namespace="microsoft.graph.callRecords" xmlns="http://docs.oasis-open.org/odata/ns/edm" xmlns:odata="http://schemas.microsoft.com/oDataCapabilities">
101+
<Schema Namespace="microsoft.graph.callRecords" Alias="callRecords" xmlns="http://docs.oasis-open.org/odata/ns/edm" xmlns:odata="http://schemas.microsoft.com/oDataCapabilities">
92102
<EntityType Name="callRecord">
93103
<Key>
94104
<PropertyRef Name="id" />
@@ -111,4 +121,4 @@ declarations) to match this example.
111121
</Schema>
112122
</edmx:DataServices>
113123
</edmx:Edmx>
114-
```
124+
```

0 commit comments

Comments
 (0)