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.43k stars 75 forks source link

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

Open pgjones opened 6 months ago

pgjones commented 6 months 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.