api-platform / api-platform/core

Add updatable to ApiProperty

Open
#5,962 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
2.6k
Forks
980
Avg merge
2d 2h
Merged PRs (30d)
51

Description

**Description**
We currently have `writable` and 'readable' on `ApiProperty` attributes.
This is great to reduce the amount of serialization group management you have to juggle.

You'll run into an issue when you try to have fields that are writable but ONLY during updates (PATCH, PUT), in cases like this you'd have to start adding serialization groups again, which is a bit annoying when you try to serialize objects as well as you then have to propagate that down.

I'd suggest adding an `updateable` field to `ApiProperty` that'll only include/exclude fields based on if it's a PUSH or POST operation.

**Example**

```php
class Foo {
#[ApiProperty(writable: false, updateable:true)]
private ?Bar bar = null;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.