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

Documentation lacking - Want to use this bundle but, frustrating #4

Open
symball opened this issue Aug 30, 2019 · 3 comments
Open

Documentation lacking - Want to use this bundle but, frustrating #4

symball opened this issue Aug 30, 2019 · 3 comments
Assignees
Labels

Comments

@symball
Copy link

symball commented Aug 30, 2019

Hello,

This is quite a good bundle and i've been trying to use it over the course of a few days but, find the documentation seriously lacking when it comes to packaging up resources. Would it be possible to please add some further documentation on actual use cases or even an example project to follow with a particular emphasis on packaging data for transmission.

Right now, I've figured out creating JsonResource then returning it in a DocumentResponse which works fine for simple things but, i'm not even sure that's correct. How do i actually add relationships, etc.? I see lots of models to base things from but, there is no clear path on actual usage.

Is there a simpler way of achieving the following from the requesthandler for example?

// Use serializer to create simple resource
$travelPointSerialized = $this->serializer->toArray($travelPoint,
                SerializationContext::create()->setGroups(['Detail'])
        );
        $dataResource =  new JsonResource(
            'TravelPoints',
            $travelPoint->getId(),
            $travelPointSerialized
        );
        return new DocumentResponse($dataResource);  
@bogomolov-dev
Copy link
Member

We're working on it today ;)

@symball
Copy link
Author

symball commented Aug 30, 2019 via email

@pmarien
Copy link
Member

pmarien commented Aug 30, 2019

Here is an example implementation: https://github.com/eosnewmedia/Examples-Symfony-JSON-API-Server

It currently contains only a very simple use case with two resource types and only fetch (GET requests), but hopefully it will help you a little bit.

I don't close this ticket now, so we later will add more features to example implementation and improve the documentation here.
But unfortunately this will take a little longer, because I just did not manage to do it in time now.

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

No branches or pull requests

3 participants