Option for Annotation-based field exclusion (@JsonSchemaIgnore or similar) #527
Replies: 1 comment 1 reply
-
Hi @anupsajjan, I didn't know this was being used in spring-ai. That's kind of cool. According to the current implementation, both the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
❗ Use Case
❌ Current Problem
Spring AI internally uses victools/jsonschema-generator to generate schemas from DTOs. I don’t directly use the generator or control its config.
I want to exclude specific fields from schema, but not from JSON serialization.
Using @JsonIgnore is not viable, as it removes the field from the API response too.
✅ Feature Request
Support an annotation like @JsonSchemaIgnore (or similar) that allows DTOs to declare schema-excluded fields directly.
This would help me exclude fields from schema without needing access to generator config.
🔍 Background
This is particularly useful in AI/LLM applications, where JSON Schema is used to guide model behavior — and leaking internal fields like IDs or metadata can confuse the model.
Would love to hear if this is already possible or if there’s a workaround.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions