Cleaner JSON schema with inline bool and string types#2476
Merged
stephenberry merged 1 commit intomainfrom Apr 13, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inline JSON Schema for bool, string, and optional variants
Resolves #2473
Summary
Primitive types (
bool,std::string,std::string_view,char) and theirstd::optionalwrappers are now inlined directly in JSON Schemapropertiesinstead of being placed in$defsand referenced via$ref.Before:
{ "properties": { "name": { "$ref": "#/$defs/std::string" }, "flag": { "$ref": "#/$defs/bool" } }, "$defs": { "std::string": { "type": "string" }, "bool": { "type": "boolean" } } }After:
{ "properties": { "name": { "type": "string" }, "flag": { "type": "boolean" } } }Nullable variants inline with the
"null"type added:{ "nickname": { "type": ["string", "null"] } }Per-field metadata from
json_schemais preserved alongside the inlined type:{ "name": { "type": "string", "description": "A name for something" } }Changes
include/glaze/json/schema.hpp: Added atypefield toglz::schemaso properties can express{"type":"..."}directly. Modified the object handler to inlinebool,str_t/char_t, andnullable_twrappers of those types instead of creating$defs/$refentries. If a user explicitly sets$refviajson_schemametadata, that is still respected.