jcrist / msgspec

A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
https://jcristharif.com/msgspec/
BSD 3-Clause "New" or "Revised" License
2.01k stars 59 forks source link

Ability to add an example to a Struct as output to the JSON schema #689

Open pgjones opened 1 month ago

pgjones commented 1 month ago

Description

Looking at https://github.com/jcrist/msgspec/blob/main/msgspec/_json_schema.py I think there is no way to give an example for the Struct to be included in the json schema. In pydantic, for example, there is a json_schema_extra meta addition https://docs.pydantic.dev/latest/concepts/json_schema/#using-json_schema_extra-with-a-dict.

I'd like to give fixed examples and see them in the generated schema.