msgspec / msgspec/msgspec

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

Open
#689 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.1k
Forks
193
Avg merge
3d 20h
Merged PRs (30d)
15

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in msgspec/_json_schema.py and review how Struct definitions are converted into JSON Schema. Compare the requested metadata behavior with Pydantic's json_schema_extra approach; done means fixed examples supplied for a Struct appear in its generated schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.