Core: Handle id and uuid with api platform

Created on 19 Nov 2018  路  3Comments  路  Source: api-platform/core

Just wondering if I am able to use API platform to handle the following table structure.

--------------
- id - auto increment - primary key
- uuid - string 
- name
- department_id
--------------
- id - auto increment - primary key
- uuid - string 
- name

I would like to use api platform to achieve the following with ApiSubresource:

GET /api/student/{uuid}

Response

{
  "uuid": "a1590004-f74b-4a10-93f0-27f17c370058",
  "name": "student1",
  "department": "/api/department/a2122004-f74b-4a10-93f0-27f17c370058"
}

Thanks.

Most helpful comment

I do something similar.
Try annotating your ID with @ApiProperty(identifier=false) and the uuid with @ApiProperty(identifier=true)

All 3 comments

it's a custom route not a subresource

I do something similar.
Try annotating your ID with @ApiProperty(identifier=false) and the uuid with @ApiProperty(identifier=true)

Thanks @bendavies . Your approach is working.

Was this page helpful?
0 / 5 - 0 ratings