[BUG] ExampleGenerator returns the string "{}" (or null) for `type: object` schemas without `properties`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
ExampleGeneratorを実装するJavaコード内でresolvePropertyToExampleとresolveModelToExampleを見つけてください。issueには、それらのファイルやテストは記載されていません。まず、提供されたOpenAPIスキーマで再現し、未解決の$ref値がどのように扱われるかを確認してください。オブジェクトスキーマにプロパティがない場合、ネストされた例とトップレベルの例の両方で、文字列やnullではなく空のJSONオブジェクトが生成されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- 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?
Description
resolvePropertyToExample returns the Java string literal "{}" for an object schema without properties and for a $ref that cannot be resolved. Json.pretty then serializes it as a JSON string ("metadata" : "{}") instead of an empty object ("metadata" : { }), so the example has the wrong type (JSON Schema Validation wright-00, 5.21).
The same happens one level up. For a top-level model type: object without properties, resolveModelToExample falls through to return null, and generate(null, ["application/json"], "Anything") returns the example null. Through the CLI this model gets unaliased first, so the operation simply has no example; only programmatic callers see null.
openapi-generator version
7.25.0 (also current master).
OpenAPI declaration file content or url
components:
schemas:
Reading:
type: object
properties:
metadata:
type: object
Steps to reproduce
generate -g html → "Example data" shows "metadata" : "{}". Expected: "metadata" : { }.
Suggest a fix
Return new LinkedHashMap<>() (an empty map) instead of the string "{}" in both branches of resolvePropertyToExample, and also for object schemas without properties in resolveModelToExample.
- 主要言語
- Java
- スター
- 26.8k
- フォーク
- 7.7k
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 141
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenAPITools/openapi-generator のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenAPITools/openapi-generator#25236 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] OpenApiEvaluator reports "default value not in enum" for numerically equal values with different scale (e.g. 1.5 and 1.50)対応中かも @mohitduhan19 が 1 日前に担当しました。 オープンIssue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenAPITools/openapi-generator#25233 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] OpenApiEvaluator emits "Unused model" warnings even when recommendations are disabled対応中かも @mohitduhan19 が 1 日前に担当しました。 オープンIssue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
OpenAPITools/openapi-generator#25232 ·
メンテナーはふだん 1 日以内に返信
-
[BUG][KOTLIN] multiplatform/jvm-ktor: `DELETE` without `requestBody` sends `"Content-Type: application/json"` with an empty body対応中かも @mohitduhan19 が 1 日前に担当しました。 オープンIssue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenAPITools/openapi-generator#25223 ·
メンテナーはふだん 1 日以内に返信
-
Issue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
OpenAPITools/openapi-generator#25218 ·
メンテナーはふだん 1 日以内に返信
OpenAPITools/openapi-generator の issue をすべて見る
似ている issue
-
`timer` rule rejects dates the engine accepts対応中かも @MFA-G が今日担当しました。 オープンbug ready
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
camunda/bpmnlint-plugin-camunda-compat#281 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
status: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
AOT compilation fails for derived delete queries returning Set対応中かも @ryujungkyun が今日担当しました。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
spring-projects/spring-data-jpa#4387 ·
メンテナーはふだん 3 日以内に返信