-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Partial update (PATCH) over REST #1722
Comments
I'm proposing to introduce an {
schema: {
'x-ts-type': Order,
'x-ts-type-options': {
partial: true,
includes: ['p1', 'p2'],
excludes: []
}
} |
The discussion about excluding/including certain properties from parameter schema has already started in #1179, let's keep it in a single place there. I'll cross-post your comment @raymondfeng. IMO, this issue should be focused on leveraging #1179 in our example projects and CLI controller templates. Alternatively, we can close is as a duplicate of #1179. |
On the second thought, maybe this issue is slightly different from #1179. In #1179, we want to allow In this issue, we want to allow all model properties in the payload, but make them all optional. Ideally, I'd like us to fine a mechanism (decorator API) that can support both use cases in a consistent way. Building on top of what has been proposed in #1179 (comment): // `id` property is not allowed for `create`:
@post('/')
createTodo(@requestBody(Todo, {propertyBlacklist: ['id']}) todo: Partial<Todo>) {}
// all properties are allowed, all are optional
@patch('/')
updateTodo(@requestBody(Todo, {partial: true}) todo: Partial<Todo>) {} Internally, |
In #2152 (comment), I mention a solution for defining types representing model data with a black-list applied.
|
hey @bajtos @raymondfeng, I was trying to compile an acceptance criteria for this issue, but noticed that it's pretty similar to #2652. Can we close it in favour of the other or do you think they're different? If so, maybe we can chat to come up with an acceptance criteria for this issue and get it groomed. |
user: Partial < User > - works for me
|
Description / Steps to reproduce / Feature proposal
Consider the following acceptance tests for Todo controller in our example apps.
Current Behavior
Both tests fail because the PATCH request fails with 422 validation error. The request body is rejected because it's not a valid Todo instance (missing required title property, etc.)
Expected Behavior
The PATCH operation behaves like a real patch, accepting a subset of Todo properties to update. Both tests pass.
Related issues:
Partial
OpenAPI decorator does not properly generate schemas of typePartial
#1179See Reporting Issues for more tips on writing good issues
The text was updated successfully, but these errors were encountered: