Skip to content

OpenAPI: JsonTypeInfoで設定されたスキーマ定義が設定されない - #2062

Merged
xsekiguchi merged 12 commits into
masterfrom
feature/2060-fix-openapi-jsontypeinfo-schema
May 19, 2026
Merged

OpenAPI: JsonTypeInfoで設定されたスキーマ定義が設定されない#2062
xsekiguchi merged 12 commits into
masterfrom
feature/2060-fix-openapi-jsontypeinfo-schema

Conversation

@xsekiguchi

@xsekiguchi xsekiguchi commented May 18, 2026

Copy link
Copy Markdown
Contributor

closes #2060

対応内容

  • クラス・プロパティに対応しOpenAPI Schemaを設定する機能を追加
  • OpenApiService にクラス・プロパティに対応するスキーマを設定可能に
  • クラスからJsonSchema解決時クラス・プロパティに対応するスキーマが存在する場合に指定スキーマを返却する実装修正

動作確認・スクリーンショット(任意)

  • 結果パラメータに org.iplass.mtp.definition.Definition を設定し OpenAPI を出力。
  • 修正後に JsonTypeInfo で設定している @class プロパティが、service-config に設定した値になっていることを確認。

レビュー観点・補足情報(任意)

  • クラスのプロパティのスキーマを検証を始める前に、Service-Config で設定したスキーマが存在するかを確認するように変更しました。

- クラス・プロパティに対応しOpenAPI Schemaを設定する機能を追加
- OpenApiService にクラス・プロパティに対応するスキーマを設定可能に
- クラスからJsonSchema解決時クラス・プロパティに対応するスキーマが存在する場合に指定スキーマを返却する実装修正

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(クラス/プロパティのスキーマ定義)を新規追加

Comment thread iplass-web/src/main/java/org/iplass/mtp/impl/webapi/openapi/OpenApiService.java Outdated
- クラス・プロパティスキーマ設定用のプロパティ名の修正(Listを除去)
- ログ出力時にログレベルの検査

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

- ログ出力内容の見直し

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

- プロパティ名は空文字でも例外をスローする
- スキーマ作成時にプロパティ設定するのは値が設定されているケースのみとする

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

- 例外メッセージの修正
- 冗長なクラス名の修正(ClassPropertySchema~ ⇒ PropertySchema~)
- 設定専用のインターフェースを削除しOpenApiComponentReusableSchemaFactoryに統合

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
			}

- クラス名リファクタリングをコメントへ反映

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

- 例外メッセージの修正

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

- doclet 修正
@xsekiguchi
xsekiguchi requested a review from HiguchiKiyoshi May 18, 2026 13:17
@xsekiguchi
xsekiguchi merged commit 02fd2b6 into master May 19, 2026
4 checks passed
@xsekiguchi
xsekiguchi deleted the feature/2060-fix-openapi-jsontypeinfo-schema branch May 19, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAPI: JsonTypeInfoで設定されたスキーマ定義が設定されない

2 participants