Support POJO/Java Class for automatic responseSchema generation
Los mantenedores suelen responder en 1 día
@hemasekhar-p ya está trabajando en esto.
Desde el 8/1/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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.
- Lenguaje dominante
- Java
- Estrellas
- 398
- Forks
- 126
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 71
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de googleapis/java-genai
-
ResponseStream.close() can block on the reader lock before closing the HTTP responsePosiblemente ocupada @hirematha la tomó hace 1 día. Abiertopriority: p2 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
googleapis/java-genai#1372 ·
Los mantenedores suelen responder en 1 día
-
Interactions API: GaosClientException.getMessage() only returns "400 . API error occurred" and omits the server error detailsPosiblemente ocupada @hemasekhar-p la tomó hace 25 días. Abiertopriority: p2 type: bug
googleapis/java-genai#1282 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Interactions API: store(false) omits "id", breaking Interaction and InteractionCompletedEvent deserializationPosiblemente ocupada @hemasekhar-p la tomó hace 25 días. Abiertopriority: p2 type: bug
googleapis/java-genai#1281 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Interaction.outputText() always returns Optional.empty() (SDK-computed field is never populated)Posiblemente ocupada @hemasekhar-p la tomó hace 25 días. Abiertopriority: p2 type: bug
googleapis/java-genai#1280 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Gen AI with structured output - `propertyOrdering` in Python vs. Java implementationsPosiblemente ocupada @hemasekhar-p la tomó hace 79 días. Abiertopriority: p3 type: feature request
googleapis/java-genai#1169 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de googleapis/java-genai
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug/错误
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
FCL-Team/FoldCraftLauncher#1982 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] micronaut-serde-oracle-jdbc-json brings a second OJDBC driver onto the runtime classpathPosiblemente ocupada @ZARAYACH la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
micronaut-projects/micronaut-serialization#1494 · 4 comentarios ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 75/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 2 días