-
Notifications
You must be signed in to change notification settings - Fork 17
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
Create resource fails with error #94
Comments
Hey, first of all, thanks for contributing! If the In the Keycloak docs there's an optional Could be that the docs are wrong, though, but would be nice to have an integration test case that verifies the error. |
I just looked it up in the source, it seems like the JSON property name is public class ResourceRepresentation {
@JsonProperty("_id")
private String id;
} Need to implement a solution to handle this 😅 I think it will break with the current logic, because it doesn't "support" underscores in property names. |
What if we would add an attribute with an alternative name? Would that work? So we can translate on serialize and deserialize? |
Yes, that would be an option I guess. I currently don't have much spare time, so I can't look into it too soon 🙈 Maybe we could built something similar and do e.g. class Resource extends Representation
{
public function __construct(
#[JsonProperty(name: '_id')]
protected ?string $id,
)
} I don't know if there are any existing PHP libraries that can already doo this 🤔 |
The best one I know and use very often: https://symfony.com/doc/current/components/serializer.html It's independent of the framework, so can be used standalone. Highly configurable and well maintained. The downside is, there is a lot of complexity, so we might run into issues that are harder to solve rather than having a simple implementation in this project |
Agree, I would like to keep it as simple as possible 👍 |
Hey, just to let you know, it's still on my radar, but I didn't get to work on that issue (yet) 😅 |
No problem, we have a workaround for now. If I find the time we can try to contribute a fix. But also here time is limited |
Maybe https://github.com/jolicode/automapper could be an option 👀 |
Hey, I've been playing around a little bit with the Symfony Serializer here: #116 Using the I had to create a custom Next I would need to add a custom normalizer (or encoder? 🤔) to handle the Feel free to leave your thoughts 😊 |
We try to setup a new realm using this library. However this fails because the Resource representation api doesn't accept the
id
field when creating a resource. We get the error:Suggestion is to filter the id field when it's not set. So on fetch the object will contain an id, but when posting a new resource to create one it will not error. I saw that a feature exists to filter properties with a certain attribute. Would this be a useful approach for the resource id as well? So the code would look like this:
Implementing it this way would allow us to reuse the behavior on other fields of representations, in the same way.
This issue relates to #93
The text was updated successfully, but these errors were encountered: