OpenAPITools / OpenAPITools/openapi-generator
[bug][symfony] AnyType is not defined
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 26.8k
- Fork
- 7.7k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
AnyType is not defined in symfony server generated code.
In some situations, schemas return any, this is handled in other languages where that is translated into something the language understands, examples:
- Java: Object
- C#: `Object
- Rust: serde_json:Value
However, this translation is not made for symfony, and the generators write AnyType in such situations, leading to type errors:
AnyType is not defined anywhere.
openapi-generator version
7.2.0
some_data:
type: object
additionalProperties: true
or
some_data:
type: object
additionalProperties: {}
when a request is made with some data , this exception is thrown by JMSSerializer in vendor/jms/metadata/src/MetadataFactory.php
curl --location --request POST 'http://localhost:8000/myservice' \
--header 'Content-Type: application/json' \
--data-raw '{
"some_data": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
}'
Uncaught PHP Exception ReflectionException: "Class "AnyType" does not exist" at MetadataFactory.php line 175
Generation Details
openapi-generator-cli \
generate \
-i openapi.yaml \
-g php-symfony \
-o .
Steps to reproduce
Related issues/PRs
its the same issue as this one was for typescript https://github.com/OpenAPITools/openapi-generator/issues/6332
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.
Direzione di ricerca
Inizia eseguendo il comando openapi-generator fornito con il generatore php-symfony e lo schema di esempio usando additionalProperties. Segui il tipo generato attraverso la gestione della richiesta fino a vendor/jms/metadata/src/MetadataFactory.php. Il lavoro è completato quando il codice Symfony generato non fa più riferimento a un AnyType non definito e il payload POST mostrato può essere gestito correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php, symfony
- Ambito
- api, backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100