-
Notifications
You must be signed in to change notification settings - Fork 4
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
Persisting an entity with a ManyToOne relation does not convert related entity as IRI #46
Comments
Well that's weird because a call to Do your API return If it does not return the full URL then I understand the problem and your solution may be the right one. Thanks again for your reports! |
Our entities do return "xxxxx" as we map the $id properties like this :
And here's a sample response from the API:
We tried mapping the "@id" property from the API to have "/articles/xxxxx" but we had a lot of issues after, maybe we should retry with the recent fixes. |
OK. At Mapado we map @id and it's fine for us but your use case is interesting! I'll try to fix it soon. |
Ok ! Just for information, we have control on the API, which is a Symfony API Platform application (https://github.com/api-platform/api-platform). On a previous project, we used Symfony + API bundle (preliminary version of API Platform) and we also had the same id/@id output in the API responses. |
Your point is very interesting. As a matter of fact, I think the id you use is not the real identifier, which is the iri (we should probably have named it Iri instead of Id everywhere :/ ). It pointed a thing that I wanted to fix for a long time: the fact the the attribute Will it be OK for you to have something like this:
This way, you keep your (Just for the record we came from dunglas api-platform too, with only |
Hi, thanks for the feedback. Just before we go ahead with trying this, can you confirm you suggest adding the annotation "@rest\Id" on both property, or is it a copy-paste mistake? |
Sorry, copy paste mistake, fixed in the previous comment ;) It will only work with #47 merged, but you can try it for now by requiring If you can confirm it's OK. |
Excellent ! We will spend some time today to try it, stay tuned. |
So far so good ! Retrieval, creation, updates and relations seem to be working as expected now with both IRI and Id fields. Thanks a lot / gros merci ! |
fixed in v0.18.3 |
We have the following entity classes:
and
When we persist an entity like this:
Then the HTTP call to the API is like this:
Notice how the "section" key is "946c3a2a-e36a-11e6-b8b0-0242ac110002" instead of "/sections/946c3a2a-e36a-11e6-b8b0-0242ac110002"
I think the fix could be to modify the Serializer::recursiveSerialize method, around line 189, by replacing:
with:
The text was updated successfully, but these errors were encountered: