Fix JSON schema metadata for dictionary keys by fallenmi · Pull Request #1159 · msgspec/msgspec · GitHub
Skip to content

Fix JSON schema metadata for dictionary keys - #1159

Open
fallenmi wants to merge 1 commit into
msgspec:mainfrom
fallenmi:agent/fix-schema-key-metadata
Open

Fix JSON schema metadata for dictionary keys#1159
fallenmi wants to merge 1 commit into
msgspec:mainfrom
fallenmi:agent/fix-schema-key-metadata

Conversation

@fallenmi

@fallenmi fallenmi commented Aug 16, 2026

Copy link
Copy Markdown

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
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

1 participant