json_serializable.dart icon indicating copy to clipboard operation
json_serializable.dart copied to clipboard

Wish for an option to generate a static method that returns a JSON Schema for this class

Open sethladd opened this issue 10 months ago • 8 comments

apologies if I missed it, if it exists!

It would be helpful to have the option to generate a static function that returns a Map or a String that contains the JSON Schema that represents this object.

This would make interoping with LLMs a little easier, as I could pass a JSON Schema to the LLM as an example of how to return a JSON for this object.

Thanks!

sethladd avatar Jun 04 '25 06:06 sethladd

Chris Sells asked for this, too. I think it exists. Let me ask what he found...

kevmoo avatar Jun 04 '25 06:06 kevmoo

This does the trick: https://pub.dev/packages/soti_schema

csells avatar Jun 04 '25 13:06 csells

Thank you! I'll check it out.

sethladd avatar Jun 05 '25 02:06 sethladd

btw, @sethladd, I wanted the exact same feature, so I added it to dartantic_ai.

csells avatar Jun 05 '25 02:06 csells

Thanks! I hope we also get this in json_serializable. This library seems to be the default when using coding agents (at least, so far!)

sethladd avatar Jun 07 '25 20:06 sethladd

@sethladd – PRs welcome. 😁

kevmoo avatar Jun 09 '25 20:06 kevmoo

that's what he said to me, too @sethladd : )

csells avatar Jun 09 '25 20:06 csells

I would also love this - our use case being generating schema to validate our backend against for automated testing.

alexobviously avatar Jul 30 '25 07:07 alexobviously