OpenAPI: JsonTypeInfoで設定されたスキーマ定義が設定されない - #2062
Merged
xsekiguchi merged 12 commits intoMay 19, 2026
Merged
Conversation
- クラス・プロパティに対応しOpenAPI Schemaを設定する機能を追加 - OpenApiService にクラス・プロパティに対応するスキーマを設定可能に - クラスからJsonSchema解決時クラス・プロパティに対応するスキーマが存在する場合に指定スキーマを返却する実装修正
Contributor
There was a problem hiding this comment.
Pull request overview
Issue #2060(JsonTypeInfo で付与される @class 等のプロパティに対して、service-config で指定した OpenAPI Schema が反映されない)を解消するために、クラス×プロパティ(またはプロパティ名のみ)でスキーマを固定上書きできる仕組みを追加し、OpenAPI スキーマ生成時に適用するよう拡張するPRです。
Changes:
- service-config からクラス/プロパティ単位の固定スキーマ定義を読み取り、解決する
ClassPropertySchemaResolverを追加 - スキーマ生成ファクトリに Resolver を注入できる
ClassPropertySchemaResolverAwareを導入し、OpenApiService から配線 - クラス→Schema 変換時に、該当プロパティが固定スキーマ定義に一致する場合は生成結果を上書き
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| iplass-web/src/main/resources/mtp-web-service-config.xml | @class 用の固定スキーマ定義を service-config に追加 |
| iplass-web/src/main/java/org/iplass/mtp/impl/webapi/openapi/OpenApiService.java | service-config から固定スキーマ定義を読み込み、スキーマ生成側へ注入 |
| iplass-web/src/main/java/org/iplass/mtp/impl/webapi/openapi/schema/OpenApiComponentReusableSchemaFactoryAssigner.java | Resolver を下位 factory へ伝搬できるよう Aware を実装 |
| iplass-web/src/main/java/org/iplass/mtp/impl/webapi/openapi/schema/OpenApiComponentClassReusableSchemaFactory.java | プロパティ単位の固定スキーマ上書きをスキーマ生成処理に追加 |
| iplass-web/src/main/java/org/iplass/mtp/impl/webapi/openapi/schema/ClassPropertySchemaResolverAware.java | Resolver 注入用インターフェースを新規追加 |
| iplass-web/src/main/java/org/iplass/mtp/impl/webapi/openapi/schema/ClassPropertySchemaResolver.java | クラス/プロパティ→Schema の解決ロジックを新規追加 |
| iplass-web/src/main/java/org/iplass/mtp/impl/webapi/openapi/schema/ClassPropertySchema.java | service-config から読み取る設定Bean(クラス/プロパティのスキーマ定義)を新規追加 |
- クラス・プロパティスキーマ設定用のプロパティ名の修正(Listを除去) - ログ出力時にログレベルの検査
- ログ出力内容の見直し
- プロパティ名は空文字でも例外をスローする - スキーマ作成時にプロパティ設定するのは値が設定されているケースのみとする
- 例外メッセージの修正
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (2)
iplass-web/src/main/java/org/iplass/mtp/impl/webapi/openapi/schema/PropertySchemaResolver.java:80
- [imo] 設定不備時の例外メッセージが "ClassPropertySchema" になっており、PropertySchema のバリデーションとして読むと不自然です(propertyName必須チェック)。メッセージの型名・文言を PropertySchema に合わせて整理してください。
// プロパティ名は必須
if (StringUtil.isEmpty(schema.getPropertyName())) {
throw new IllegalArgumentException(
"ClassPropertySchema must have non-empty propertyName. className=" + schema.getClassName());
}
iplass-web/src/main/java/org/iplass/mtp/impl/webapi/openapi/schema/PropertySchemaResolver.java:87
- [imo] 設定不備時の例外メッセージが "ClassPropertySchema" になっていますが、PropertySchema の schemaType 必須チェックとしては誤解を招きます。メッセージ中の型名を PropertySchema に合わせてください。
// スキーマタイプは必須
if (schema.getSchemaType() == null) {
throw new IllegalArgumentException(
"ClassPropertySchema must have non-null schemaType. className=" + schema.getClassName()
+ ", propertyName=" + schema.getPropertyName());
}
- クラス名リファクタリングをコメントへ反映
- 例外メッセージの修正
- doclet 修正
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #2060
対応内容
動作確認・スクリーンショット(任意)
@classプロパティが、service-config に設定した値になっていることを確認。レビュー観点・補足情報(任意)