Expected Behavior
Be able to generate more complex schemas with the BeanOutputConverter
class, for instance with constrains definitions like max elements in array and max or min length for strings. This can be handled adding support to the definition of what modules should be loaded for jsonschema-generator library. Could be allowing override the private method generateSchema
or adding it as a constructor parameter.
Current Behavior
Right now the BeanOutputConverter
is adding just the jackson-module to the configuration of jsonschema-generator library, this is a great starting point to have a schema definition but does not allow the definition of more complex scenarios. The code to generate the value for jsonSchema field is private so we cannot override it to adding more modules to the libray.
Context
Under some circumstances we can ask to the AI model to generate content with specific rules, for instance if we want to generate specific number of answers for one question. In that case we can specify it with the prompt but probably could be a good idea add it as a constraint to the expected schema just to be sure the AI model respect it. This can be handled with the maven library jsonschema-module-jakarta-validation. I tested locally and just add it to the jsonschema-generator library configuration it's enough to add constraints to the generated schema.
Comment From: Seol-JY
@csterwa
Is this feature still not implemented? I'd like to contribute to add Jakarta Validation support to BeanOutputConverter
for constraint annotations like @Size
, @Min
, etc.
Would a PR be welcome? I'm thinking of adding support for jsonschema-module-jakarta-validation
while maintaining backward compatibility.
I know this might not be easy for a beginner like me, but I'd like to give it a try!
Thanks!
Comment From: csterwa
It is great to see your interest in providing a PR for this. There is a help wanted
label on this issue. I'm going summon @tzolov or @markpollack to provide guidance on the approach, if any?