Support POJO/Java Class for automatic responseSchema generation
メンテナーはふだん 1 日以内に返信
@hemasekhar-p がすでに取り組んでいます。
2026年1月8日 から。
評価
この issue はまだ評価されていません。
説明
Is your feature request related to a problem? Please describe.
I am frustrated when I have to manually define the responseSchema using complex builders, even though I already have well-structured DTO (Data Transfer Object) classes in my Java project.
Currently, the Java SDK requires developers to manually construct a Schema object. This leads to redundant work and high maintenance costs, as any change in the Java class must be manually reflected in the Schema builder. For example, in a project with many complex DTOs, this manual mapping is highly error-prone and degrades the Developer Experience (DX).
Describe the solution you'd like
I would like the GenerateContentConfig.Builder to support an overloaded responseSchema(Class<?> clazz) method. This method should automatically introspect the provided Java class (POJO/Record) and generate the corresponding Schema object.
Desired Usage:
// Instead of manual Schema building
GenerateContentConfig config = GenerateContentConfig.builder()
.responseMimeType("application/json")
.responseSchema(MyResponseDto.class) // Passing the DTO class directly
.build();
The SDK should ideally use reflection or existing Jackson integration to map Java types (String, Integer, List, etc.) to the Gemini Type system.
Describe alternatives you've considered
I have considered the Python Gen AI SDK, which already provides this functionality through Pydantic models. Python developers can simply pass a class to response_schema, and the SDK handles the rest.
Currently, in Java, I have to write a custom utility using jsonschema-generator and map it back to the SDK's Schema object. This feels like a feature that should be natively supported to ensure "Feature Parity" across different language SDKs.
Additional context
Since the SDK already utilizes Jackson (@JsonProperty), implementing this wouldn't necessarily require heavy new dependencies. The implementation could respect Jackson annotations:
@JsonPropertyDescription: To populate thedescriptionfield in the schema.@JsonProperty: To handle custom field naming.
This enhancement would make the Java SDK feel much more "idiomatic" and productive for enterprise-level backend development.
- 主要言語
- Java
- スター
- 398
- フォーク
- 126
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 71
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/java-genai のほかの issue
-
priority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
googleapis/java-genai#1372 ·
メンテナーはふだん 1 日以内に返信
-
Interactions API: GaosClientException.getMessage() only returns "400 . API error occurred" and omits the server error details対応中かも @hemasekhar-p が 24 日前に担当しました。 オープンpriority: p2 type: bug
googleapis/java-genai#1282 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Interactions API: store(false) omits "id", breaking Interaction and InteractionCompletedEvent deserialization対応中かも @hemasekhar-p が 24 日前に担当しました。 オープンpriority: p2 type: bug
googleapis/java-genai#1281 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Interaction.outputText() always returns Optional.empty() (SDK-computed field is never populated)対応中かも @hemasekhar-p が 24 日前に担当しました。 オープンpriority: p2 type: bug
googleapis/java-genai#1280 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Gen AI with structured output - `propertyOrdering` in Python vs. Java implementations対応中かも @hemasekhar-p が 78 日前に担当しました。 オープンpriority: p3 type: feature request
googleapis/java-genai#1169 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
googleapis/java-genai の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
oracle/graalvm-reachability-metadata#11472 ·
メンテナーはふだん 1 日以内に返信
-
status: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
spring-projects/spring-ai#7269 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 89/100
objectionary/hone-maven-plugin#1353 ·
メンテナーはふだん 9 日以内に返信
-
ClassNotFoundException: io.netty.channel.kqueue.KQueueEventLoop stack trace printed during native build on main (Netty 4.2 removed the class)対応中かも @gastaldi が今日担当しました。 オープンarea/netty kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
quarkusio/quarkus#57939 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
conductor-oss/conductor#1777 ·
メンテナーはふだん 4 日以内に返信