{"action":"created","issue":{"url":"https://api.github.com/repos/api-platform/core/issues/1982","repository_url":"https://api.github.com/repos/api-platform/core","labels_url":"https://api.github.com/repos/api-platform/core/issues/1982/labels{/name}","comments_url":"https://api.github.com/repos/api-platform/core/issues/1982/comments","events_url":"https://api.github.com/repos/api-platform/core/issues/1982/events","html_url":"https://github.com/api-platform/core/issues/1982","id":327139749,"number":1982,"title":"[Help needed] Normalization context groups does not add relations as object ","user":{"login":"Caaliitis","id":3831903,"avatar_url":"https://avatars2.githubusercontent.com/u/3831903?v=4","gravatar_id":"","url":"https://api.github.com/users/Caaliitis","html_url":"https://github.com/Caaliitis","followers_url":"https://api.github.com/users/Caaliitis/followers","following_url":"https://api.github.com/users/Caaliitis/following{/other_user}","gists_url":"https://api.github.com/users/Caaliitis/gists{/gist_id}","starred_url":"https://api.github.com/users/Caaliitis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Caaliitis/subscriptions","organizations_url":"https://api.github.com/users/Caaliitis/orgs","repos_url":"https://api.github.com/users/Caaliitis/repos","events_url":"https://api.github.com/users/Caaliitis/events{/privacy}","received_events_url":"https://api.github.com/users/Caaliitis/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-05-29T00:53:31Z","updated_at":"2018-05-29T20:42:59Z","closed_at":"2018-05-29T20:42:59Z","author_association":"NONE","body":"I have entities\r\n```\r\n/**\r\n * @ApiResource(attributes={\"denormalizationContext\" = {\"groups\"={\"get_coupon\"}}})\r\n * @ORM\\HasLifecycleCallbacks()\r\n * @ORM\\Entity(repositoryClass=\"App\\Repository\\CouponRepository\")\r\n * @ApiFilter(SearchFilter::class,properties={\"user\":\"exact\"})\r\n */\r\nclass Coupon\r\n{\r\n    /**\r\n     * @ORM\\ManyToOne(targetEntity=\"App\\Entity\\Company\")\r\n     * @Groups({\"get_coupon\"})\r\n     */\r\n    public $company;\r\n```\r\n\r\nAnd the relation one\r\n```\r\n\r\n/**\r\n * @ApiResource()\r\n * @ORM\\HasLifecycleCallbacks()\r\n * @ORM\\Entity(repositoryClass=\"App\\Repository\\CompanyRepository\")\r\n * @ApiFilter(SearchFilter::class,properties={\"user\":\"exact\"})\r\n */\r\nclass Company\r\n{\r\n    /**\r\n     * @Assert\\NotBlank()\r\n     * @ORM\\Column(type=\"string\", unique=true, length=191)\r\n     * @Groups({\"get_coupon\",\"get_company\"})\r\n     */\r\n    public $name;\r\n```\r\nIt is basically done as in documentation and i use the newest symfony 4 and api platform.\r\nI am getting\r\n```\r\n{\r\n    \"@context\": \"/api/contexts/Coupon\",\r\n    \"@id\": \"/api/coupons/20\",\r\n    \"@type\": \"Coupon\",\r\n    \"id\": 20,\r\n    \"company\": \"/api/companies/1\"\r\n}\r\n```\r\nAl though in the documentation its said i should get \r\n```\r\n{\r\n    \"@context\": \"/api/contexts/Coupon\",\r\n    \"@id\": \"/api/coupons/20\",\r\n    \"@type\": \"Coupon\",\r\n    \"id\": 20,\r\n    \"company\": {\r\n        \"id\": 1,\r\n        \"name\": \"Company name\"\r\n    }\r\n}\r\n````\r\nOnly way how to achieve company as object is only by removing `@ApiResource` in Company entity.\r\nFor all of my not bundle basic configs i use annotations\r\nRemoving `ApiResource` Is not a possibility, because i need this kind of relations to a lot of different entities and in the same time for most of them i need the basic crud functionallity\r\n\r\nHow to achieve [this](https://api-platform.com/docs/core/serialization/#normalization) ? Have been looking for days and even trying to rewrite and redo base of the project, but nothing.\r\n\r\nPackages from composer:\r\n```\r\n\"php\": \"^7.1.3\",\r\n        \"ext-iconv\": \"*\",\r\n        \"api-platform/api-pack\": \"^1.1\",\r\n        \"cocur/slugify\": \"^3.1\",\r\n        \"friendsofsymfony/comment-bundle\": \"dev-master\",\r\n        \"friendsofsymfony/user-bundle\": \"dev-master\",\r\n        \"fullpipe/twig-webpack-extension\": \"^2.0\",\r\n        \"liip/imagine-bundle\": \"^2.0\",\r\n        \"paypal/rest-api-sdk-php\": \"^1.13\",\r\n        \"sensio/framework-extra-bundle\": \"^5.1\",\r\n        \"sonata-project/admin-bundle\": \"^3.31\",\r\n        \"sonata-project/classification-bundle\": \"^3.6\",\r\n        \"sonata-project/comment-bundle\": \"^3.1\",\r\n        \"sonata-project/core-bundle\": \"^3.9\",\r\n        \"sonata-project/doctrine-orm-admin-bundle\": \"^3.4\",\r\n        \"sonata-project/intl-bundle\": \"^2.4\",\r\n        \"sonata-project/media-bundle\": \"^3.9\",\r\n        \"sonata-project/notification-bundle\": \"^3.3\",\r\n        \"sonata-project/user-bundle\": \"^4.1\",\r\n        \"stof/doctrine-extensions-bundle\": \"^1.3\",\r\n        \"symfony/acl-bundle\": \"^1.0\",\r\n        \"symfony/apache-pack\": \"^1.0\",\r\n        \"symfony/asset\": \"^4.0\",\r\n        \"symfony/console\": \"^4.0\",\r\n        \"symfony/debug-pack\": \"*\",\r\n        \"symfony/expression-language\": \"^4.0\",\r\n        \"symfony/flex\": \"^1.0\",\r\n        \"symfony/form\": \"^4.0\",\r\n        \"symfony/framework-bundle\": \"^4.0\",\r\n        \"symfony/lts\": \"^4@dev\",\r\n        \"symfony/maker-bundle\": \"dev-master#40456950e7d93bb13f3406c0097d899bf5625793\",\r\n        \"symfony/monolog-bundle\": \"^3.1\",\r\n        \"symfony/orm-pack\": \"*\",\r\n        \"symfony/process\": \"^4.0\",\r\n        \"symfony/security-acl\": \"dev-master\",\r\n        \"symfony/security-bundle\": \"^4.0\",\r\n        \"symfony/serializer\": \"^4.0\",\r\n        \"symfony/serializer-pack\": \"*\",\r\n        \"symfony/swiftmailer-bundle\": \"^3.1\",\r\n        \"symfony/templating\": \"^4.0\",\r\n        \"symfony/twig-bridge\": \"^4.0\",\r\n        \"symfony/validator\": \"^4.0\",\r\n        \"symfony/web-link\": \"^4.0\",\r\n        \"symfony/webpack-encore-pack\": \"*\",\r\n        \"symfony/yaml\": \"^4.0\"\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/api-platform/core/issues/comments/392937008","html_url":"https://github.com/api-platform/core/issues/1982#issuecomment-392937008","issue_url":"https://api.github.com/repos/api-platform/core/issues/1982","id":392937008,"user":{"login":"Caaliitis","id":3831903,"avatar_url":"https://avatars2.githubusercontent.com/u/3831903?v=4","gravatar_id":"","url":"https://api.github.com/users/Caaliitis","html_url":"https://github.com/Caaliitis","followers_url":"https://api.github.com/users/Caaliitis/followers","following_url":"https://api.github.com/users/Caaliitis/following{/other_user}","gists_url":"https://api.github.com/users/Caaliitis/gists{/gist_id}","starred_url":"https://api.github.com/users/Caaliitis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Caaliitis/subscriptions","organizations_url":"https://api.github.com/users/Caaliitis/orgs","repos_url":"https://api.github.com/users/Caaliitis/repos","events_url":"https://api.github.com/users/Caaliitis/events{/privacy}","received_events_url":"https://api.github.com/users/Caaliitis/received_events","type":"User","site_admin":false},"created_at":"2018-05-29T20:42:59Z","updated_at":"2018-05-29T20:42:59Z","author_association":"NONE","body":"Works!"}}
{"actor":{"display_login":"Caaliitis"}}