Skip to content

rfl::json::to_schema<T, rfl::DefaultIfMissing>: emit "type" before "default" on Boolean and normalize annotation order #115

Done

Description

@clockblocker

Bug

Under rfl::json::to_schema<T, rfl::DefaultIfMissing>, boolean fields serialize "default" before "type" (e.g., {"default": false, "type": "boolean"} instead of {"type": "boolean", "default": false}), and several composite schema structs emit flattened Annotations (description, deprecated, default) ahead of primary structural keywords (items, additionalProperties, oneOf), causing noisy schema diffs.

Evidence & Root Cause

  • Surfaced in clockblocker/slang-server#1 (bf857f4):
    • slang-server/clients/vscode/resources/config.schema.json:89-93
    • tests/json/test_json_schema_default_if_missing.cpp:170
  • Root cause on fork/all-planned-prs (7a8ab835) in include/rfl/json/schema/Type.hpp:28-31:
    • struct Boolean declares rfl::Flatten<Annotations> annotations{}; before Literal<"boolean"> type{};, whereas Integer, Number, String, Null, Object, TypedArray, FixedSizeTypedArray, StringMap, Tuple, StringEnum, and Regex all declare type first.
    • Additionally, Annotations (which carries defaultValue → "default") appears before items / additionalProperties / oneOf / anyOf / allOf on composite schema types in include/rfl/json/schema/Type.hpp:53-155.

Acceptance Criteria

  • Move Literal<"boolean"> type{}; ahead of rfl::Flatten<Annotations> annotations{}; in rfl::json::schema::Type::Boolean so booleans consistently emit "type" before "default" / "description", matching all other primitive schema types.
  • Audit and normalize "default" / Annotations ordering relative to items, additionalProperties, and oneOf where appropriate (without breaking existing schema tests; update tests/json/test_json_schema_default_if_missing.cpp:170 and add regression assertions checking "type" precedes "default" on booleans).

Activity

  1. added
    bug
    ready-for-agent
    on Nov 27, 2026
  2. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Landed on showcase/all-lanes at b73c8aea (dual-Judge approved by claude-opus-5-5 high + gemini-4-neon high; 467/467 targets 0 warnings, 1,129/1,129 CTests).

    • Reordered rfl::json::schema::Type::Boolean so Literal<"boolean"> type precedes rfl::Flatten<Annotations> annotations, matching every other primitive subtype.
    • Audited all 21 json::schema::Type subtypes, updated test_json_schema_default_if_missing.cpp, and added test_issue_115_boolean_type_before_default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions