OpenAPITools / OpenAPITools/openapi-generator
[bug][symfony] AnyType is not defined
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 26.8k
- フォーク
- 7.7k
- PR マージ指標
- PR 指標を取得中
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された openapi-generator コマンドを php-symfony ジェネレーターと additionalProperties を使用するサンプルスキーマで実行します。生成された型を、vendor/jms/metadata/src/MetadataFactory.php に到達するリクエスト処理を通して追跡します。生成された Symfony コードが未定義の AnyType を参照しなくなり、示されている POST ペイロードを正常に処理できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php, symfony
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100