Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 07 2019 15:07
    torinaki closed #45
  • May 07 2019 15:07
    torinaki commented #45
  • Apr 16 2019 15:02
    torinaki closed #42
  • Apr 16 2019 15:02
    torinaki commented #42
  • Feb 01 2019 08:34
    torinaki commented #45
  • Feb 01 2019 08:34
    torinaki opened #45
  • Jan 24 2019 16:49
    torinaki commented #42
  • Aug 13 2018 10:13
    torinaki closed #44
  • Aug 13 2018 10:13
    torinaki commented #44
  • Aug 13 2018 10:12
    torinaki opened #44
  • Jul 27 2018 13:13
    vlady777 commented #43
  • Jul 27 2018 13:12
    vlady777 closed #43
  • Jul 27 2018 13:11
    vlady777 opened #43
  • Jun 26 2018 15:15
    torinaki commented #42
  • Jun 22 2018 08:50
    oleg-andreyev commented #42
  • Jun 20 2018 15:47
    torinaki commented #42
  • Jun 07 2018 16:30
    torinaki commented #42
  • May 25 2018 07:36
    torinaki commented #34
  • May 24 2018 18:47
    torinaki commented #34
  • May 24 2018 18:45
    torinaki commented #34
Steffen
@koemeet
Test
Steffen
@koemeet
@szachara Hey,
@szachara You need to add an exclusion strategy manually atm. I already have one for you, simple get json_api.serializer.relationship_exclusion_strategy this one from the container.
I need to add this automatically in a nice way.
Steffen
@koemeet
{
    "data": [
        {
            "type": "posts",
            "id": 1,
            "attributes": {
                "tiiitel": "My post",
                "description": "This is the first post"
            },
            "relationships": {
                "comments": {
                    "data": [
                        {
                            "type": "comments",
                            "id": 1
                        }
                    ]
                }
            }
        },
        {
            "type": "posts",
            "id": 3,
            "attributes": {
                "tiiitel": "My third post",
                "description": "This is the third post"
            },
            "relationships": {
                "comments": {
                    "data": []
                }
            }
        }
    ],
    "included": [
        {
            "type": "comments",
            "id": 1,
            "attributes": {
                "title": "This is a comment title",
                "body": "My body"
            },
            "relationships": {
                "post": {
                    "data": {
                        "type": "posts",
                        "id": 1
                    }
                },
                "author": {
                    "data": {
                        "type": "people",
                        "id": 1
                    }
                }
            }
        },
        {
            "type": "people",
            "id": 1,
            "attributes": {
                "name": "Piet Kees",
                "age": 21
            }
        }
    ]
}
This for example is valid.
Silver Zachara
@szachara
I wasn't 100% sure, if they can be there, but if you are absolutely sure, so everything is OK.
they say nothing that is only is for the primary resource. They just say that the resource object MAY have relationships.
They don't explicitly say that it is valid for included relationships, but from what I read I think it is perfectly valid.
If it would not be valid, JSON-API would not be as good also :P
Silver Zachara
@szachara
They say nothing about that and it confused me little. You have created your own exclusion strategy for this problem, so closed and resolved. Man you are superfast.
Amazing
Steffen
@koemeet
Yeah I will make sure it will be added automatically in the future, but for now you always need this line when using FOSRestBundle:
$view->setSerializationContext(SerializationContext::create()->addExclusionStrategy($this->get('json_api.serializer.relationship_exclusion_strategy')));
Silver Zachara
@szachara
Only for sure, I checked it on json api issue tracker and it's valid
Steffen
@koemeet
Great ;)
You do not need to manually enable the exclusion strategy anymore.
I have overridden the Serializer and made sure both fos rest and jms have their aliases set to this libs serializer .
Silver Zachara
@szachara
I see it, done through DI. Would not be better to set this exclusion strategy exactly before serialization? I'm asking because whether will not be affected other bundles, when the will use json serialization through jms serializer. If they will not, so it's OK. I'm not familiar with DI aliases.
Steffen
@koemeet
Well they are used so you can replace them easily
@szachara You cannot set the exclusion strategy automatically before the serialization without overriding the serializer.
You just want to install jms/serializer-bundle and steffenbrem/json-api-bundle and then when you use $this->get('serializer')->serialize($post, 'json'); you want to have it all working.
or maybe introduce a new type, specifically for json-api? So you need to do $this->get('serializer')->serialize($post, 'json-api').
@szachara What do you think about something like that?
Silver Zachara
@szachara
I think new type will be without any problems, this type will be used only for serializing json api, so it doesn't affect other json serialization. Or I have other solution, it's not so elegant, but may be it will work. Simply extend serializer class, there you can manually add exclusion strategy and exactly before serialization will be used only this extended class.
Steffen
@koemeet

@szachara That is kind of what I am doing know, the problem is is that it will be complicated for the user, since they need to know this new serializer.

I think I will make it register itself under json-api within JMS serializer. And will figure something out to make FOSRestBundle handle that too.

This way you can also serialize basic json with JMS.
Silver Zachara
@szachara
Great will be ideal
Steffen
@koemeet
Sorry for some slow work sometimes, but I am on vacation so I cannot work as much as usual.
Drew Clauson
@drewclauson
Hello all, I'm newer to Symfony/FOSRestBundle and creating an ember app and am working on using JSON API. I'd be happy to contribute building this out, let me know if there are areas that I can be of help in.
Steffen
@koemeet
Hey @drewclauson I am too using my library for Ember, so if you encouter something I probably need it too! :)
Drew Clauson
@drewclauson
@steffenbrem Just back from vacation and paternity leave - thanks, I'm starting to use it this week and will contribute as I find things that I need!
Drew Clauson
@drewclauson
@steffenbrem Are you doing any remote pagination in your implementation? I was looking into it noticed that the JSONAPI spec appears to help pagination along with links, but couldn't find any documentation on if ember-data 2.0 can access those links at this point. Just wanted to see if you've done anything with pagination yet that makes more use of JSONAPI before I venture down the path of a mixin like ember-cli-pagination
Steffen
@koemeet
@drewclauson Yes, this bundle integrates with Pagerfanta, so you can use a Pagerfanta object as your data source and it will make a proper JSON-API response for you :)
Drew Clauson
@drewclauson
Thanks!
Drew Clauson
@drewclauson
@steffenbrem, I'm curious - I noticed you had some activity on neomerx/json-api previously - what made you decide to go with your own bundle and jms serializer?
Steffen
@koemeet
I needed a solid serializer, so I could use serialization groups etc. for security purposes. I was indeed planning on integrating neomerx/json-api in Symfony2 using metadata drivers too etc. but I already got a draft of a json-api working with JMSSerializer and so this speeds things up for the project I am currenly working on.
Although I think, now that PHP7 is getting more stable, using JMSSerializer is very nice. You can nicely hook into things and the recursion was a problem in PHP 5.6 and below, but now in PHP7 the performance difference with neomerx/json-api it is negligible.
Steffen
@koemeet
I also know JMSSerializer a lot better than neomerx/json-api, so paginated stuff etc. I could easily implement it to make that automatically work nice with existing Symfony2 bundles (ones using Pagerfanta).
Drew Clauson
@drewclauson
Thanks! I appreciate your thoughts on it - I did decide to use json-api and make a bundle to integrate it into Symfony with their limoncello package since I'm not as familiar with serialization in general and with JSON-API. It also had some filters, strict checking of the request and some error handling that was helpful. I am concerned about the serializer performance as well, but time I found I needed to serialize some things a little more explicitly than I thought I could with JMSSerializer, but I may have just not gotten deep enough into it. Thanks again!
Have you made the jump to PHP7 in any of your work? I'm considering switching to it from 5.6, but don't know if all of the Symfony bundles I'm using will support it, although Symfony currently claims that they support it.
Sergey
@chernecov
Hello.
@koemeet , what do you think about moving out "willdurand/hateoas": ">2.0" from composer? It is kinda compatibility dependency and not required for bundle to work.
Sergey
@chernecov
Same goes for pagerfanta
It would help to keep dependency map thin
Oleg Andreyev
@oleg-andreyev
hi @koemeet! Can you create LICENCE to JsonApiBundle?