We are using ApiPlatform for 2 years to develop our API. Some properties are (denormalized/normalized) different like on write using IRI reference but on read show nested properties instead.
Even we can update and set the iri reference example on the property like:
class PlaceOpportunityUsage extends AbstractEntityHasId
{
/**
* @var PlaceOpportunity|null
*/
#[ORM\ManyToOne(targetEntity: PlaceOpportunity::class)]
#[ORM\JoinColumn(referencedColumnName: 'id', nullable: false)]
#[ApiProperty(example: '/api/opportunities/{id}')]
#[Groups(['OpportunityUsage:write', 'OpportunityUsage:read'])]
private ?PlaceOpportunity $opportunity = null;
We think ApiPlatform has feature to automatically set the IRI reference and put to property example without explicitly specify. Also when we set example like that, on each request body/response this property appears as large. But some requests normalizing this property as nested and returns nested object like that:
{
"@id": "/api/opportunity/usages/10",
"@type": "PlaceOpportunityUsage",
"opportunity": {
"@id": "/api/instant/opportunities/31",
"@type": "PlaceOpportunity",
"status": true,
"place": {
"@id": "/api/places/2ffeab17-13d8-458a-abf8-f20d3ba7a08f",
"@type": "Place",
"name": "Uncle Wingman",
"id": "2ffeab17-13d8-458a-abf8-f20d3ba7a08f",
"createdAt": "2025-07-08",
"updatedAt": "2026-05-11"
},
"dayInterval": [
"MONDAY",
"TUESDAY",
"FRIDAY",
"SATURDAY"
],
....
},
....
}
I want to show different examples on POST or GET requests. When I remove the #[ApiProperty] attribute on the property, at this time the request shows that property example as http://example.com, because we couldn't find documentation about iris property in the ApiProperty instance, we tought field for setting reference examples this didn't work.
We are using ApiPlatform 3.2, and we cannot update our version yet.
Is there a way to fix this issue?
We are using ApiPlatform for 2 years to develop our API. Some properties are (denormalized/normalized) different like on write using IRI reference but on read show nested properties instead.
Even we can update and set the iri reference example on the property like:
We think ApiPlatform has feature to automatically set the IRI reference and put to property example without explicitly specify. Also when we set example like that, on each request body/response this property appears as large. But some requests normalizing this property as nested and returns nested object like that:
{ "@id": "/api/opportunity/usages/10", "@type": "PlaceOpportunityUsage", "opportunity": { "@id": "/api/instant/opportunities/31", "@type": "PlaceOpportunity", "status": true, "place": { "@id": "/api/places/2ffeab17-13d8-458a-abf8-f20d3ba7a08f", "@type": "Place", "name": "Uncle Wingman", "id": "2ffeab17-13d8-458a-abf8-f20d3ba7a08f", "createdAt": "2025-07-08", "updatedAt": "2026-05-11" }, "dayInterval": [ "MONDAY", "TUESDAY", "FRIDAY", "SATURDAY" ], .... }, .... }I want to show different examples on POST or GET requests. When I remove the #[ApiProperty] attribute on the property, at this time the request shows that property example as
http://example.com, because we couldn't find documentation aboutirisproperty in the ApiProperty instance, we tought field for setting reference examples this didn't work.We are using ApiPlatform 3.2, and we cannot update our version yet.
Is there a way to fix this issue?