Skip to content

Conversation

haya14busa
Copy link
Contributor

@haya14busa haya14busa commented Jul 5, 2025

Summary

This PR adds support for the unevaluatedProperties keyword from JSON Schema draft 2019-09/2020-12.

Problem

When using JSON Schema with unevaluatedProperties, quicktype was generating incorrect types. For example, in Go, it would generate map[string]interface{} instead of properly typed maps like map[string][]SomeType.

Solution

When additionalProperties is not defined in a schema, quicktype now falls back to using unevaluatedProperties to determine the type of additional properties in an object.

Changes

  • Modified JSONSchemaInput.ts to handle unevaluatedProperties when additionalProperties is undefined
  • Added test cases with JSON Schema using unevaluatedProperties

Test

Added test schema and data files:

  • test/inputs/schema/unevaluated-properties.schema
  • test/inputs/schema/unevaluated-properties.1.json
  • test/inputs/schema/unevaluated-properties.2.json

The tests can be run with:

QUICKTEST=true FIXTURE=schema-golang npm test

Example

Before this fix:

type ChecksumConfig struct {
    EmbeddedChecksums map[string]interface{} `json:"embedded_checksums,omitempty"`
}

After this fix:

type ChecksumConfig struct {
    EmbeddedChecksums map[string][]EmbeddedChecksum `json:"embedded_checksums,omitempty"`
}

Add support for the unevaluatedProperties keyword from JSON Schema draft 2019-09/2020-12.
When additionalProperties is not defined, unevaluatedProperties is now used as a fallback
to determine the type of additional properties in an object.

This fixes issues where objects using unevaluatedProperties would generate incorrect
types (e.g., map[string]interface{} instead of properly typed maps in Go).
@haya14busa haya14busa force-pushed the fix-unevaluated-properties-support branch from dd63fbd to af0c9ff Compare July 5, 2025 13:32
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.

1 participant