-
Notifications
You must be signed in to change notification settings - Fork 304
JSON merge-patch support #7207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON merge-patch support #7207
Conversation
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
…name templates when visibilityMode is CreateOrUpdate.
|
|
||
| [RFC 7396](https://www.rfc-editor.org/rfc/rfc7396) describes a standard for interpreting | ||
| a Patch request body using content-type `application/merge-patch+json`to update an existing | ||
| resource. The TypeSpec Http library provides Model templates `MergePatchUpdate` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| resource. The TypeSpec Http library provides Model templates `MergePatchUpdate` and | |
| resource. The TypeSpec HTTP library provides Model templates `MergePatchUpdate` and |
| - `quantity` may or ay not occur in the request, if it does occur, the resource value can be updated to a new integer value or erased by sending null. | ||
| - `color` may or may not occur in the request, if it does occur, the resource value can be updated to one of the appropriate values. If set to `null` it is returned to its default value (`blue`) | ||
| - `flavor` may or may not occur in the request, if it does occur, the resource value can be updated to one of the appropriate values. If set to `null` it is returned to its default value (`vanilla`) | ||
| - `related` may or may not occur in the request, if it does occur, the resource value can be updated or erased (set to `{}`) by sending null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Erased" in this context (related) should set the value of the resource so that it has no related record, not an empty record, right? Are records special in this respect? It seems like if you had a resource with related: { ... } and you wanted to set it to related: {}, you would have to first send related: null and then related: {}.
| Because JSON merge-patch only describes the request body of an http request, the merge-patch | ||
| transform in TypeSpec does not allow http envelope property metadata like `@query`, `@path`, | ||
| `@header`, `@cookie`, and `@statusCode` in http requests. | ||
|
|
||
| The merge-patch templates will **emit an error diagnostic** if a model containing Http metadata | ||
| properties is passed in. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Because JSON merge-patch only describes the request body of an http request, the merge-patch | |
| transform in TypeSpec does not allow http envelope property metadata like `@query`, `@path`, | |
| `@header`, `@cookie`, and `@statusCode` in http requests. | |
| The merge-patch templates will **emit an error diagnostic** if a model containing Http metadata | |
| properties is passed in. For example: | |
| Because JSON merge-patch only describes the request body of an HTTP request, the merge-patch | |
| transform in TypeSpec does not allow HTTP envelope property metadata like `@query`, `@path`, | |
| `@header`, `@cookie`, and `@statusCode` in HTTP requests. | |
| The merge-patch templates will **emit an error diagnostic** if a model containing HTTP metadata | |
| properties is passed in. For example: |
|
|
||
| // THIS WILL RESULT IN AN ERROR | ||
| @patch op update(...MergePatchUpdate<ResourceWithMetadata>): ResourceWithMetadata; | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps worth mentioning also that it is invalid to pass a model into MergePatchUpdate or MergePatchCreateOrUpdate that contains null anywhere in its ordinary value space, since null has special meaning in JSON Merge Patch.
fix #7221(
@mediaTypeHintnot allowing media types with suffix)