Swagger document different property content for POST and GET requests
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di api-platform/core
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
api-platform/core#8573 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
api-platform/core#8571 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
api-platform/core#8564 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
api-platform/core#8495 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
api-platform/core#8471 ·
Tutte le issue di api-platform/core
Issue simili
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Automattic/safe-publish#594 ·
-
needs-triage Platform(Default)
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
HttpClient
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
symfony/symfony-docs#23092 ·
-
sync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
sync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100