Skip to content

Commit bae0b0e

Browse files
authored
Fix Dictionary guidance to use PATCH to add/remove/update properties.
1 parent 192ef66 commit bae0b0e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

graph/patterns/dictionary.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ The API design requires a resource to include an unknown quantity of data elemen
1010

1111
## Solution
1212

13-
API designers use a JSON object to represent a dictionary in an `application/json` response payload. When describing the model in CSDL, a new complex type can be created that derives from `Org.OData.Core.V1.Dictionary` and then uses the `Org.OData.Validation.V1.OpenPropertyTypeConstraint` to constrain the type that can be used for the values in the dictionary.
13+
API designers use a JSON object to represent a dictionary in an `application/json` response payload. When describing the model in CSDL, a new complex type can be created that derives from `Org.OData.Core.V1.Dictionary` and then uses the `Org.OData.Validation.V1.OpenPropertyTypeConstraint` to constrain the type that can be used for the values in the dictionary as appropriate.
1414

15-
Dictionary entries can be added via `POST`, updated via `PATCH`, and removed by setting the entry value to `null`. Multiple entries can be updated at the same time by using `PATCH` on the dictionary property.
15+
Dictionary values can be added, removed, or modified via `PATCH` to the dictionary property. Values are removed by setting the property to `null`.
1616

1717
## When to use this pattern
1818

@@ -36,8 +36,9 @@ Because dictionary entries are removed by setting the value to `null`, dictionar
3636
Open questions:
3737

3838
- Can/should PUT be supported on the dictionary property and/or the entry value?
39-
- What does OData say about being able to POST to a structured property? Will OData Web API allow that?
4039
- Must an implementer support PATCH at both the dictionary level and the entry level?
40+
- Should we also allow DELETE to a property to be equivalent to setting to null?
41+
- Why do we not allow mixed primitives or mixed primitive/complex typed values? what about collections?
4142

4243
For more information, see the [OData reference](https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Core.V1.md#dictionary).
4344

@@ -130,7 +131,7 @@ Response:
130131
#### Create an entry in the dictionary
131132

132133
```HTTP
133-
POST https://graph.microsoft.com/v1.0/users/10/roles/author
134+
PATCH https://graph.microsoft.com/v1.0/users/10/roles/author
134135
135136
{
136137
"domain": "contoso"
@@ -175,7 +176,10 @@ PATCH https://graph.microsoft.com/v1.0/users/10/roles/author
175176
#### Delete an entry from the dictionary
176177

177178
```HTTP
178-
DELETE https://graph.microsoft.com/v1.0/users/10/roles/author
179+
PATCH https://graph.microsoft.com/v1.0/users/10/roles/author
180+
{
181+
"domain": null
182+
}
179183
```
180184

181185
### CDSL example
@@ -200,8 +204,6 @@ The following example defines a complex type **roleSettings** as well as a dicti
200204
<Collection><!-- use this annotation to indicate you want the SDKs to generate additional request builders to update the dictionary automatically -->
201205
<String>GET</String>
202206
<String>PATCH</String>
203-
<String>DELETE</String>
204-
<String>POST</String>
205207
<Collection>
206208
</Annotation>
207209
</ComplexType>

0 commit comments

Comments
 (0)