Skip to content

Fix JSON schema metadata for dictionary keys - #1159

Merged
Siyet merged 1 commit into
msgspec:mainfrom
fallenmi:agent/fix-schema-key-metadata
Sep 13, 2026
Merged

Siyet merged 1 commit into
msgspec:mainfrom
fallenmi:agent/fix-schema-key-metadata

Conversation

@fallenmi

@fallenmi fallenmi commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #866.

Dictionary key annotations with JSON Schema metadata are represented internally as Metadata wrappers. The dictionary schema branch only recognized a bare StrType, so adding metadata such as title caused both that metadata and string constraints to disappear from propertyNames.

This change verifies that the wrapped key is a string, generates propertyNames from the original annotated key schema, and removes the redundant string type. Existing behavior for plain and constraint-only string keys is preserved.

Validation:

  • Full unit suite: 6412 passed, 113 skipped
  • JSON Schema tests: 124 passed, 2 skipped
  • Doctests: 7 passed
  • Repository hooks: lint, format, and spelling passed

AI assistance disclosure: OpenAI Codex helped investigate, implement, and test this change. The account owner authorized publication; upstream workflows still require maintainer approval before they can run.

@fallenmi
fallenmi marked this pull request as ready for review August 25, 2026 12:41

@Siyet Siyet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the fix! Metadata and string constraints are now preserved for annotated dictionary keys.

@Siyet
Siyet added this pull request to the merge queue Sep 13, 2026
Merged via the queue into msgspec:main with commit 9bec541 Sep 13, 2026
28 of 29 checks passed
@bimac

bimac commented Sep 14, 2026

Copy link
Copy Markdown

Thanks for the fix, @fallenmi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

json schema: propertyNames only shows up under specific conditions

3 participants