Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Swagger document different property content for POST and GET requests

Aperta
#8,477 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
openapi, php
Ambito
api, documentation

Direzione di ricerca

Inizia riproducendo l’output Swagger/OpenAPI generato per le operazioni POST e GET su ApiPlatform 3.2, utilizzando l’esempio PlaceOpportunityUsage e il relativo comportamento di ApiProperty, Groups e normalizzazione annidata. Traccia quindi il modo in cui vengono prodotti gli schemi delle operazioni e gli esempi delle proprietà, poi verifica se è possibile rappresentare esempi di IRI specifici dell’operazione e di proprietà annidate. Il lavoro è completo quando le diverse uscite POST/GET sono supportate oppure la limitazione è documentata chiaramente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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?

Lingua principale
PHP
Stelle
2.6k
Fork
982
Merge medio
1g 16h
PR unite (30g)
59

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di api-platform/core

Tutte le issue di api-platform/core

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.