[BUG] OpenApiEvaluator emits "Unused model" warnings even when recommendations are disabled
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
調査の方向性
modules/openapi-generator と OpenApiEvaluator.java を読み、未使用スキーマのチェックを issue に記載された推奨事項のチェックと比較します。提供された Maven Wrapper のテストコマンドを実行し、OpenApiEvaluatorJUnitTest.ct07GlobalRecommendationsOffSuppressUnusedSchema を調べます。このテストが成功し、グローバルな推奨事項が無効なときに未使用スキーマの警告が抑制されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
OpenApiEvaluator.validate(OpenAPI) reports unused schemas (Unused model: <name>) even when recommendations are globally disabled (RuleConfiguration.isEnableRecommendations() == false). All other recommendations respect this flag: default not in enum, header with underscore, and GET/HEAD with request body. Only the unused-schema check ignores it. Recommendations are optional best-practice warnings that the evaluator should emit only when recommendations are enabled.
Environment
- Project: OpenAPI Generator v7.25.0 (fork), commit
ef964b04480889ef86b56cfae84ade8ad4c91c41 - Module:
modules/openapi-generator - Class/method:
org.openapitools.codegen.validations.oas.OpenApiEvaluator#validate(OpenAPI) - OS: Linux 7.0.0-38-generic (amd64)
- Java: OpenJDK 25 (compiled with source/target 11)
- Tests: JUnit 5.10.2 + Mockito 4.10.0, run with the Maven Wrapper (Surefire 3.2.5)
Steps to reproduce
- Create an OpenAPI 3.0 document with a schema under
components/schemasthat is not referenced anywhere (e.g.Orphan). - Create a
RuleConfigurationwithisEnableRecommendations() = falseandisEnableUnusedSchemasRecommendation() = true(the default). - Call
new OpenApiEvaluator(config).validate(openAPI). - Inspect
getWarnings()on the result.
Automated test case: CT-OE-07 (OpenApiEvaluatorJUnitTest.ct07GlobalRecommendationsOffSuppressUnusedSchema).
./mvnw -pl modules/openapi-generator -am test -Dtest=OpenApiEvaluatorJUnitTest -Dsurefire.failIfNoSpecifiedTests=false
Expected result
No recommendation warnings, since recommendations are globally disabled.
Actual result
unused-schema recommendation emitted while recommendations are disabled: [Unused model: Orphan]
==> expected: <true> but was: <false>
The failure occurred in all 3 Surefire attempts (rerunFailingTestsCount = 2), so it is not flaky.
Root cause
In OpenApiEvaluator.java, line 46, the unused-schema block checks only its own flag:
if (ruleConfiguration.isEnableUnusedSchemasRecommendation()) {
The default-not-in-enum rule (line 61) and the delegated validators (OpenApiSchemaValidations, OpenApiParameterValidations, OpenApiOperationValidations, OpenApiSecuritySchemeValidations) all check the global isEnableRecommendations() flag first.
Impact
- The CLI
validatecommand without--recommendcallssetEnableRecommendations(false)(Validate.java, lines 71–72). It still lists unused schemas as warnings and ends with "Spec has N recommendation(s)". - The Maven plugin's
validategoal also disables recommendations (ValidateMojo.java, line 377). From reading the code, withstrictSpec = truea single unused schema is enough to fail the goal (lines 245 and 252). This plugin behavior was identified by code reading only and was not executed.
Suggested fix
Require both flags, as the default-not-in-enum rule does:
if (ruleConfiguration.isEnableRecommendations()
&& ruleConfiguration.isEnableUnusedSchemasRecommendation()) {
- 主要言語
- Java
- スター
- 26.8k
- フォーク
- 7.7k
- 平均マージ
- 1日 15時間
- マージ済み PR(30日)
- 146
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenAPITools/openapi-generator のほかの issue
-
[BUG][RUST] Reqwest - encoding of spaces in path parameters対応中かも @GlenWright が今日担当しました。 オープンIssue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
OpenAPITools/openapi-generator#25257 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] ExampleGenerator returns the string "{}" (or null) for `type: object` schemas without `properties`対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenAPITools/openapi-generator#25237 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] OpenApiEvaluator reports "default value not in enum" for numerically equal values with different scale (e.g. 1.5 and 1.50)対応中かも @mohitduhan19 が 2 日前に担当しました。 オープンIssue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenAPITools/openapi-generator#25233 ·
メンテナーはふだん 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
-
:maddi-inspection-kotlin:test runs out of heap in a full maddi test run; exit 1 with no failing testオープンbuild/ci front-end:kotlin
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
uwolfer/gerrit-intellij-plugin#768 ·
メンテナーはふだん 1 日以内に返信
-
github_actions
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
hiero-ledger/hiero-consensus-node#27621 ·
メンテナーはふだん 1 日以内に返信
-
x:knowledge/elementary x:module/practice-exercise
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100