Support POJO/Java Class for automatic responseSchema generation
I maintainer di solito rispondono entro 1 giorno
@hemasekhar-p ci sta già lavorando.
Dal 8/1/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 398
- Fork
- 126
- Merge medio
- 1g 12h
- PR unite (30g)
- 71
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di googleapis/java-genai
-
priority: p2 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
googleapis/java-genai#1372 ·
I maintainer di solito rispondono entro 1 giorno
-
Interactions API: GaosClientException.getMessage() only returns "400 . API error occurred" and omits the server error detailsForse già presa @hemasekhar-p l’ha presa 24 giorni fa. Apertapriority: p2 type: bug
googleapis/java-genai#1282 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Interactions API: store(false) omits "id", breaking Interaction and InteractionCompletedEvent deserializationForse già presa @hemasekhar-p l’ha presa 24 giorni fa. Apertapriority: p2 type: bug
googleapis/java-genai#1281 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Interaction.outputText() always returns Optional.empty() (SDK-computed field is never populated)Forse già presa @hemasekhar-p l’ha presa 24 giorni fa. Apertapriority: p2 type: bug
googleapis/java-genai#1280 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Gen AI with structured output - `propertyOrdering` in Python vs. Java implementationsForse già presa @hemasekhar-p l’ha presa 78 giorni fa. Apertapriority: p3 type: feature request
googleapis/java-genai#1169 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di googleapis/java-genai
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
quarkiverse/quarkus-google-cloud-services#1188 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
opendataloader-project/opendataloader-pdf#851 ·
I maintainer di solito rispondono entro 1 giorno
-
Component: Frontend Component: Web Component Type: Maintenance
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
it-at-m/refarch-templates#1944 ·
I maintainer di solito rispondono entro 2 giorni
-
3.0.0-M*: every channel stays reachable from its session's KEX listeners, so a long-lived session leaks all closed channelsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno