Repository navigation
Emit JSON Schema defaults for rfl::DefaultIfMissing (#396) - #78
Open
clockblocker wants to merge 7 commits into
Open
clockblocker wants to merge 7 commits into
clockblocker wants to merge 7 commits into
Conversation
This was referenced Nov 27, 2026
…d reference guards
…throwing is_empty
…essors, decouple View)
clockblocker
force-pushed
the
json-schema-default-if-missing
branch
from
November 27, 2026 20:52
addde84 to
8c37c58
Compare
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.
Summary
Extends
rfl::json::to_schema<T, rfl::DefaultIfMissing>()to emit JSON Schema"default"annotations for default-constructible struct fields (including in-class member initializers), matchingrfl::DefaultIfMissingread semantics while leavingto_schema<T>()withoutDefaultIfMissingcompletely unchanged.Closes munich-data-engineering#396 (Note:
#21covers wrappedrfl::DefaultValfields separately.)Details
Parser_default::make_referencesafely constructsT{}insidetry / catch (...)whenrfl::DefaultIfMissingis active andstd::is_default_constructible_v<T>holds, falling back cleanly without defaults if construction throws.NamedTupleParser::add_field_to_schemaserializes field defaults fromT{}viarfl::to_generic<ProcessorsType>(insidetry / catch (...)), preserves explicitrfl::DefaultValfields without duplication, and skips emitting"default": nullfor empty nullable fields (std::optional,std::unique_ptr,std::shared_ptr, raw pointers) while emitting initialized values (including falsy0/false/"").Variant,Rename,Description,Deprecated,DefaultVal,Commented,Skip,Validator) sostd::is_default_constructible_vaccurately reportsfalsefor wrapped non-default-constructible types.tests/json/test_json_schema_default_if_missing.cpp, updatedtests/json/test_json_schema4.cpp, and documented behavior indocs/content/json_schema.md.Verification
ctest -R "(schema|default)": 76/76 PASSED.ctestsuite under-Wall -Werror: 592/592 PASSED.