JSON Schema: Reference-count guided inlining and schema/schematic merge#2501
Merged
stephenberry merged 4 commits intomainfrom Apr 15, 2026
Merged
JSON Schema: Reference-count guided inlining and schema/schematic merge#2501stephenberry merged 4 commits intomainfrom
stephenberry merged 4 commits intomainfrom
Conversation
|
One of the tests failed for 0ee41e0. @admin check logs https://download.copr.fedorainfracloud.org/results/packit/stephenberry-glaze-2501/fedora-rawhide-s390x/10332576-glaze/builder-live.log, packit dashboard https://dashboard.packit.dev/jobs/copr/3475869 and external service dashboard https://copr.fedorainfracloud.org/coprs/build/10332576/ |
|
One of the tests failed for e7d688f. @admin check logs https://download.copr.fedorainfracloud.org/results/packit/stephenberry-glaze-2501/fedora-rawhide-s390x/10332583-glaze/builder-live.log, packit dashboard https://dashboard.packit.dev/jobs/copr/3475873 and external service dashboard https://copr.fedorainfracloud.org/coprs/build/10332583/ |
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.
JSON Schema: Reference-count guided inlining and schema/schematic merge
Addresses #2469
Overview
$defsentries that are referenced only once are now inlined at their$refsite. Multi-use entries remain in$defsas before.Before (struct with a single
Addressfield):{ "properties": { "address": { "$ref": "#/$defs/Address" } }, "$defs": { "Address": { "type": "object", "properties": { ... } } } }After:
{ "properties": { "address": { "type": "object", "properties": { ... } } } }When a type is referenced from multiple sites, it stays in
$defswith$refas before.Implementation
The inlining operates on the typed
schematree before serialization — no JSON parsing/re-serialization round-trip.count_schema_refs— walks the tree counting$refstring occurrencestry_inline_ref— for single-use$refnodes, moves the definition from$defsinto the reference site, merging any sibling metadata (e.g.title,description)inline_single_use_refs— recursive traversal that applies inlining at every reference site (properties, items, additionalProperties, oneOf, prefixItems), with chained resolution for nested single-use typesprune_inlined_defs— removes consumed entries; drops$defsentirely when emptyUnified
schematypeschemaanddetail::schematicare merged into a singleschemastruct. This eliminates the type mismatch that previously prevented typed inlining (propertiesstoredschemabut definitions wereschematic).glz::json_schema<T>specializations continue to work with designated initializers (schema x{.description = "...", .minimum = 0})properties,items,oneOf,defs, etc.) are at the bottom of the struct, allstd::optionaldefaulting to nullitemsandadditionalPropertiesusestd::shared_ptr<schema>to break the recursive type cycle while keepingschemacopyableglz::meta<schema>) moved to an external specialization (required because the self-referential container members need the type to be complete)Other changes
merge_schema_attrsapplies userjson_schemametadata with merge semantics rather than wholesale assignment, preserving generated fields (e.g. a user-specifiedminimumno longer discards the type'smaximum)make_primitive_schemareturnsstd::shared_ptr<schema>(wasschema) to match the newitems/additionalPropertiestypeopenapi.hppandhttp_server.hppupdated fromdetail::schematictoschema