Skip to content

fix referencing objects through multiple ref files - #112

Merged
mikee47 merged 2 commits into
mikee47:developfrom
pljakobs:fix/cross-file-alias
Oct 9, 2026
Merged

mikee47 merged 2 commits into
mikee47:developfrom
pljakobs:fix/cross-file-alias

Conversation

@pljakobs

@pljakobs pljakobs commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

in my json-rpc schema, I use three layers of ref

  • json-rpc.cfgdb maps message names to message content
  • params.cfgdb builds the actual payload structure that can be used by html or json-rpc transports
  • value-types.cfgdb defines the datatypes, which can be simple values like string or numerals or objects like rgb

When a params object referred to by json-rpc itself references an object in value-types, the object in value types is correctly put into the params object by value, but the include is put into json-rpc.h

This patch registeres the obejct with the correct intermediate file

@mikee47

mikee47 commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Can you point me to your schema - I'd like to make sure this scenario is covered in the tests

@pljakobs

pljakobs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

I have used a minimal schema to show the issue
top.cfgdb:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "message": { "$ref": "mid/$defs/mid-obj" }
  }
}

mid.cfgdb:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "mid-obj": {
      "type": "object",
      "properties": {
        "name": { "$ref": "leaf/$defs/scalar" },
        "inner": { "$ref": "leaf/$defs/comp" }
      },
      "additionalProperties": false
    }
  }
}

leaf.cfgdb:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "scalar": {
      "type": "string"
    },
    "comp": {
      "type": "object",
      "properties": {
        "a": { "$ref": "#/$defs/scalar" },
        "b": { "$ref": "#/$defs/scalar" }
      },
      "additionalProperties": false
    }
  }
}

building this with the existing dbgen.py will insert the include for leaf.h into top.h while mid.h has

        struct __attribute__((packed)) Struct {
            ContainedComp::Struct inner{};
            ConfigDB::StringId name{};
        };

I believe this has never surfaced before since it just won't be an issue when a schema only has two files.
In my actual firmware, I am reconsidering the decision to have three layers, but the issue seems legitimate.

Without revision, fails to build as `mid.h` missing references to `leaf.h`
@mikee47
mikee47 merged commit 7fd0fea into mikee47:develop Oct 9, 2026
17 of 18 checks passed
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.

2 participants