OpenAPITools / OpenAPITools/openapi-generator
[bug][symfony] AnyType is not defined
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied openapi-generator command with the php-symfony generator and the example schema using additionalProperties. Trace the generated type through the request handling that reaches vendor/jms/metadata/src/MetadataFactory.php. Done means generated Symfony code no longer refers to an undefined AnyType and the shown POST payload can be handled successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100