Support POJO/Java Class for automatic responseSchema generation
Maintainer thường phản hồi trong vòng 1 ngày
@hemasekhar-p đang làm issue này rồi.
Từ ngày 8/1/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 398
- Fork
- 126
- Merge trung bình
- 1 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 71
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/java-genai
-
ResponseStream.close() can block on the reader lock before closing the HTTP responseCó thể đã có người làm @hirematha đã nhận 1 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
googleapis/java-genai#1372 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Interactions API: GaosClientException.getMessage() only returns "400 . API error occurred" and omits the server error detailsCó thể đã có người làm @hemasekhar-p đã nhận 25 ngày trước. Đang mởpriority: p2 type: bug
googleapis/java-genai#1282 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Interactions API: store(false) omits "id", breaking Interaction and InteractionCompletedEvent deserializationCó thể đã có người làm @hemasekhar-p đã nhận 25 ngày trước. Đang mởpriority: p2 type: bug
googleapis/java-genai#1281 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Interaction.outputText() always returns Optional.empty() (SDK-computed field is never populated)Có thể đã có người làm @hemasekhar-p đã nhận 25 ngày trước. Đang mởpriority: p2 type: bug
googleapis/java-genai#1280 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Gen AI with structured output - `propertyOrdering` in Python vs. Java implementationsCó thể đã có người làm @hemasekhar-p đã nhận 79 ngày trước. Đang mởpriority: p3 type: feature request
googleapis/java-genai#1169 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/java-genai
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 2 ngày
-
code-health feature/sync OS/Android QA/Test-Plan-Specified QA/Yes
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
brave/brave-browser#60327 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
aws/context-ontology-accelerator#325 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
The README tells to run `mvn jeo:disassemble`, which fails with `No plugin found for prefix 'jeo'`Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
objectionary/jeo-maven-plugin#1938 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
effort/l priority/p2 risk/high triage/deferred
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
iflytek/skillhub#1039 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày