-
-
Notifications
You must be signed in to change notification settings - Fork 960
Closed
Labels
Description
I have 2 entities, Product and Supplier
<?php
/**
* @ApiResource(
* itemOperations={
* "get"={
* "normalization_context"={"groups"={"single-read"}},
* },
* },
* )
* @ORM\Table(name="product")
* @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
* @ApiFilter(SearchFilter::class, properties={"id": "exact", "supplier": "exact"})
*/
class Product
{
/**
* @ApiProperty(identifier=true)
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Supplier", inversedBy="products")
* @ORM\JoinColumn(name="supplier_id", referencedColumnName="id")
* @Groups({"single-read"})
*/
private $supplier;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"single-read"})
*/
private $sku;
}<?php
/**
* @ORM\Table(name="supplier")
* @ORM\Entity(repositoryClass="App\Repository\SupplierRepository")
* @ApiResource(
* attributes={
* "normalization_context"={"groups"={"read"}},
* "denormalization_context"={"groups"={"write"}},
* },
* )
* @ApiFilter(SearchFilter::class, properties={"id": "exact", "code": "exact", "name": "exact"})
*/
class Supplier
{
/**
* @ApiProperty(identifier=true)
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, unique=true)
* @Groups({"read", "write", "single-read"})
*/
private $code;
/**
* @ORM\Column(type="string", length=255, unique=true)
* @Groups({"read", "write", "single-read"})
*/
private $name;
}When I use 'application/json' as response content type, properties 'code' and 'name' are exposed.
If I'm using 'application/vnd.api+json' I always see dereferencable IRI,
"relationships": {
"supplier": {
"data": {
"type": "Supplier",
"id": "/api/suppliers/73"
}
}
}Am I missing something in the configuration or this is a bug ?
Reactions are currently unavailable