Skip to content
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

Add updatable to ApiProperty #5962

Open
KDederichs opened this issue Nov 10, 2023 · 4 comments
Open

Add updatable to ApiProperty #5962

KDederichs opened this issue Nov 10, 2023 · 4 comments

Comments

@KDederichs
Copy link
Contributor

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

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

stale bot commented Jan 9, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 9, 2024
@KDederichs
Copy link
Contributor Author

I'd still like something like that, so not stale

@stale stale bot removed the stale label Jan 9, 2024
@soyuka
Copy link
Member

soyuka commented Jan 10, 2024

okay added the enhancement label, I think that you should use a DTO for each of the use cases so that you can have writable only for PATCH

@KDederichs
Copy link
Contributor Author

You could yeah.

I've run into this while using the setup with Micro Mapper Ryan introduced in https://symfonycasts.com/screencast/api-platform-extending .

It mainly enabled me to seperate it in that way, but using it I've run into the "need" for an updatable only property to keep it "simple"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants