Locastic / ApiPlatformTranslationBundle

Translation bundle for ApiPlatform based on Sylius translation
MIT License
84 stars 27 forks source link

Usage question about Api Platforms json-response #65

Open ocramleznem opened 1 year ago

ocramleznem commented 1 year ago

I'm playing with this bundle on Api Platform 3. I've setup some examples and my responses for a GET-Request on http://localhost/test_entities/91656d77-1db8-4294-a841-004dc365fbb6 look like

{
  "@context": "/contexts/TestEntity",
  "@type": "TestEntity",
  "id": "91656d77-1db8-4294-a841-004dc365fbb6",
  "name": "deutscher name",
  "description": "deutsche beschreibung",
  "products": [],
  "translations": {
    "de": {
      "@type": "TestEntityTranslation",
      "@id": "/.well-known/genid/6b50a3758975475ca57e",
      "id": "192620a2-c8a1-45bd-8809-785e1a27f4cb",
      "name": "deutscher name",
      "description": "deutsche beschreibung",
      "locale": "de"
    },
    "en": {
      "@type": "TestEntityTranslation",
      "@id": "/.well-known/genid/dc4fadb73b87e7475f3f",
      "id": "e0d4ef95-f21c-4318-b182-9b00ed627de8",
      "name": "english name",
      "description": "english description",
      "locale": "en"
    }
  },
  "translation": {
    "@type": "TestEntityTranslation",
    "@id": "/.well-known/genid/6b50a3758975475ca57e",
    "id": "192620a2-c8a1-45bd-8809-785e1a27f4cb",
    "name": "deutscher name",
    "description": "deutsche beschreibung",
    "locale": "de"
  },
  "translationLocales": [
    "de",
    "en"
  ]
}

I'm not sure about if I missed something or it's just the way it works :). My expectation was to get something like the shown json but without these doubles. Additionally on extending the request with ?locale=de I still get the whole response shown up here. Any hints for me so far without extracting the whole codebase here?

I am using API-Platform 3.1.17 and with Doctrine ORM 2.16.2.

paullla commented 1 year ago

hey @ocramleznem can you send me the code of your entity and translation entity? Maybe you added some extra serialization groups, so the response returns more data because of that.