Skip to content

refactor: remove duplicate jsonschema properties from schema files where apropos #818

Open
@kbroch-rivosinc

Description

@kbroch-rivosinc

The following commands just find properties that are defined more than once. It's not foolproof (ex: inst.name should be defined differently than csr.name), but still finds some useful examples:

[email protected]:~/rvi/non-repo-repos/riscv-unified-db on  main via  v22.14.0 via 🐍 v3.13.3 via 💎 v2.6.10
❯ for file in schemas/*.json; do jq -c '.properties | keys[]' "$file" 2>/dev/null; done | sort | uniq -c  | sort | tail -13

   1 "writeOnly"
   2 "base"
   2 "description"
   2 "marketing_name"
   2 "processor_kind"
   2 "state"
   2 "url"
   3 "introduction"
   5 "$source"
   6 "long_name"
   7 "kind"
   7 "name"
   8 "$schema"

From that list I think some of these are unnecessary duplicates.

marketing_name:

❯ for file in schemas/*.json; do echo -n "$file: "; jq '.properties.marketing_name' "$file"; done | grep -v null

schemas/manual_schema.json: {
  "type": "string",
  "description": "The publicly displayed manual name"
}
schemas/profile_class_schema.json: {
  "type": "string",
  "description": "The publicly displayed profile class name"
}

processor_kind:

❯ for file in schemas/*.json; do echo -n "$file: "; jq '.properties.processor_kind' "$file"; done | grep -v null

schemas/proc_cert_class_schema.json: {
  "type": "string",
  "enum": [
    "Generic Unprivileged",
    "Microcontroller",
    "Apps Processor"
  ],
  "description": "What kind of class is this?"
}
schemas/profile_class_schema.json: {
  "type": "string",
  "enum": [
    "Generic Unprivileged",
    "Microcontroller",
    "Apps Processor"
  ],
  "description": "What kind of class is this?"
}

url??

❯ for file in schemas/*.json; do echo -n "$file: "; jq '.properties.url' "$file"; done | grep -v null

schemas/manual_schema.json: {
  "type": "string",
  "format": "uri",
  "description": "URL to the repository"
}
schemas/manual_version_schema.json: {
  "type": "string",
  "format": "uri",
  "description": "URL to the version, if stored external to the database"
}

Would we want the duplicate as the description might help authors put in the correct URL?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions