{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/openaxia-com/json-schema/openaxia-com-replacement-result-schema.json",
  "title": "ReplacementResult",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/openaxia-com-openapi.json#/components/schemas/ReplacementResult",
  "type": "object",
  "required": [
    "query",
    "resolution",
    "target",
    "specMatching",
    "groups",
    "statedParts",
    "insufficient",
    "unchecked",
    "override",
    "excludedCounts",
    "disclaimer",
    "generatedAt",
    "provenance"
  ],
  "properties": {
    "query": {
      "type": [
        "object",
        "null"
      ],
      "description": "Null for /api/v1/products/{slug}/replacements.",
      "properties": {
        "raw": {
          "type": "string"
        },
        "brand": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "slug": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          }
        },
        "modelKey": {
          "type": "string"
        },
        "torqueSpeedHint": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "torqueNm": {
              "type": "number"
            },
            "rpm": {
              "type": "number"
            },
            "ruleId": {
              "type": "string"
            }
          }
        }
      }
    },
    "resolution": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "resolved",
            "resolved_edition",
            "series_only",
            "ambiguous",
            "not_found"
          ]
        },
        "resolvedVia": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "product_key",
            "exact",
            "model_group",
            "edition",
            "series_token",
            "duplicate",
            "index",
            null
          ]
        },
        "candidates": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ReplacementProductSummary"
          },
          "description": "ambiguous: choose one (max 10); series_only: current sizes of the series."
        },
        "groupMembers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ReplacementProductSummary"
          }
        },
        "note": {
          "type": [
            "string",
            "null"
          ]
        },
        "truncated": {
          "type": "boolean",
          "description": "The named series has more sizes than the listed cap (60): series_only candidates are the first page. The exact size was still looked up across the whole series."
        },
        "truncatedText": {
          "type": [
            "string",
            "null"
          ]
        },
        "suggestions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ReplacementProductSummary"
          },
          "description": "status not_found or ambiguous only: up to 10 fuzzy search hits that were not resolved to a product (\"did you mean\" links, never a target). Empty otherwise. id is null while public URLs are on; use slug / path / url."
        },
        "suggestionsText": {
          "type": [
            "string",
            "null"
          ],
          "description": "\"Did you mean one of these?\" when suggestions is non-empty, else null."
        }
      }
    },
    "target": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "product",
            "virtual"
          ]
        },
        "product": {
          "oneOf": [
            {
              "$ref": "#/$defs/ReplacementProductSummary"
            },
            {
              "type": "null"
            }
          ]
        },
        "series": {
          "type": [
            "object",
            "null"
          ],
          "description": "Series of a model query (series_token / series_only). `id` is null while public URLs are on.",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ]
            },
            "name": {
              "type": "string"
            },
            "slug": {
              "type": "string"
            },
            "brand": {
              "type": "object",
              "properties": {
                "slug": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          }
        },
        "assumption": {
          "type": [
            "string",
            "null"
          ],
          "description": "Virtual target sentence, or which values came from the requester (torque/rpm/diameter/voltage params)."
        },
        "lifecycle": {
          "type": "string"
        },
        "speedBasis": {
          "type": "string",
          "enum": [
            "load",
            "no_load",
            "unknown"
          ]
        },
        "specs": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/ReplacementSpecValue"
          }
        }
      }
    },
    "specMatching": {
      "type": "string",
      "enum": [
        "ok",
        "insufficient_data",
        "not_tubular",
        "no_target"
      ]
    },
    "groups": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "tier": {
            "type": "string",
            "enum": [
              "a",
              "b",
              "c",
              "d"
            ]
          },
          "label": {
            "type": "string"
          },
          "matches": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/ReplacementMatch"
            }
          }
        }
      }
    },
    "statedParts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "partNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "brand": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "slug": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "requiredChanges": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "crown",
                    "drive",
                    "bracket",
                    "adapter",
                    "controller",
                    "wiring",
                    "other"
                  ]
                },
                "text": {
                  "type": "string"
                },
                "partNumber": {
                  "type": "string"
                }
              }
            }
          },
          "evidence": {
            "$ref": "#/$defs/ReplacementEvidence"
          },
          "label": {
            "type": "string"
          }
        }
      }
    },
    "insufficient": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "heading": {
          "type": "string"
        },
        "missing": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "field": {
                "type": "string",
                "enum": [
                  "torque",
                  "speed",
                  "diameter",
                  "supply"
                ]
              },
              "reason": {
                "type": "string",
                "enum": [
                  "not_published",
                  "not_yet_collected",
                  "conflict",
                  "limit_only"
                ]
              },
              "text": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "unchecked": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "tier": {
            "type": "string",
            "enum": [
              "a",
              "b",
              "c",
              "d"
            ]
          },
          "count": {
            "type": "integer"
          },
          "missing": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "productIds": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Deprecated numeric ids; null while public URLs are on. Use productKeys."
          },
          "productKeys": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "API identifiers of the unchecked products (ReplacementProductSummary.slug rule)."
          },
          "text": {
            "type": "string"
          },
          "catalogPath": {
            "type": [
              "string",
              "null"
            ],
            "description": "Catalogue listing of the tier's scope: `/products?product_line=…&brand=…[&series=…]` (b = same series, c = same brand, d = product line). The catalogue has no missing-field filter; this is the closest filtered view."
          },
          "catalogUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "Absolute catalogPath; null while public URLs are disabled."
          }
        }
      }
    },
    "override": {
      "type": [
        "object",
        "null"
      ],
      "description": "Requester values (torque/rpm/diameter/voltage params): requested, applied to the target, ignored with a reason. Null when none were given.",
      "properties": {
        "requested": {
          "type": "object",
          "properties": {
            "torque": {
              "type": [
                "number",
                "null"
              ]
            },
            "rpm": {
              "type": [
                "number",
                "null"
              ]
            },
            "diameter": {
              "type": [
                "number",
                "null"
              ]
            },
            "voltage": {
              "type": [
                "number",
                "null"
              ]
            }
          }
        },
        "applied": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "torque",
              "rpm",
              "diameter",
              "voltage"
            ]
          }
        },
        "ignored": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "field": {
                "type": "string",
                "enum": [
                  "torque",
                  "rpm",
                  "diameter",
                  "voltage"
                ]
              },
              "reason": {
                "type": "string",
                "enum": [
                  "product_value",
                  "no_target"
                ],
                "description": "product_value = the resolved product publishes this value (never replaced); no_target = no brand, or torque/rpm/diameter incomplete, so nothing could be compared."
              }
            }
          }
        },
        "text": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "excludedCounts": {
      "type": "object",
      "additionalProperties": {
        "type": "integer"
      }
    },
    "disclaimer": {
      "type": "string"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "provenance": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string"
        },
        "tolerances": {
          "type": "string"
        },
        "tiersRequested": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "a",
              "b",
              "c",
              "d"
            ]
          }
        },
        "candidatePool": {
          "type": "object",
          "properties": {
            "recalled": {
              "type": "integer"
            },
            "truncated": {
              "type": "boolean"
            }
          }
        }
      }
    }
  },
  "$defs": {
    "ReplacementEvidence": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "claim",
            "certification_match",
            "human_review",
            "spec_comparison"
          ]
        },
        "claimId": {
          "type": [
            "string",
            "null"
          ]
        },
        "verifiedAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "referenceUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "rationale": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "ReplacementMatch": {
      "type": "object",
      "properties": {
        "product": {
          "$ref": "#/$defs/ReplacementProductSummary"
        },
        "tier": {
          "type": "string",
          "enum": [
            "a",
            "b",
            "c",
            "d"
          ]
        },
        "grade": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "direct",
            "with_changes",
            null
          ]
        },
        "label": {
          "type": "string"
        },
        "matched": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ReplacementMatchLine"
          }
        },
        "differences": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/ReplacementMatchLine"
              },
              {
                "type": "object",
                "properties": {
                  "severity": {
                    "type": "string",
                    "enum": [
                      "consequence"
                    ]
                  }
                }
              }
            ]
          }
        },
        "notes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "requiredChanges": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "crown",
                  "drive",
                  "bracket",
                  "adapter",
                  "controller",
                  "wiring",
                  "other"
                ]
              },
              "text": {
                "type": "string"
              },
              "partNumber": {
                "type": "string"
              }
            }
          }
        },
        "notChecked": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "item": {
                "type": "string",
                "enum": [
                  "head_and_adapters",
                  "brackets",
                  "remote_pairing",
                  "wiring"
                ]
              },
              "text": {
                "type": "string"
              }
            }
          }
        },
        "weakEvidence": {
          "type": "boolean"
        },
        "evidence": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ReplacementEvidence"
          }
        }
      }
    },
    "ReplacementMatchLine": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string"
        },
        "targetValue": {
          "description": "Number, text or list of values.",
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": [
                  "string",
                  "number"
                ]
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "candidateValue": {
          "description": "Number, text or list of values.",
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": [
                  "string",
                  "number"
                ]
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "delta": {
          "type": [
            "number",
            "null"
          ]
        },
        "basis": {
          "type": "object",
          "properties": {
            "target": {
              "type": [
                "string",
                "null"
              ]
            },
            "candidate": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "text": {
          "type": "string"
        }
      }
    },
    "ReplacementProductSummary": {
      "type": "object",
      "required": [
        "id",
        "slug",
        "publicId",
        "path",
        "url",
        "displayName",
        "label",
        "modelCode",
        "partNumber",
        "aliases",
        "brand",
        "series",
        "lifecycle",
        "speedBasis",
        "specs"
      ],
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Deprecated numeric id; null while MOTOBASE_PUBLIC_URLS_ENABLED is on (the API never outputs numeric ids then). Use slug or publicId."
        },
        "slug": {
          "type": "string",
          "description": "API identifier, same rule as GET /api/v1/products/{slug}: the canonical URL segment with public URLs on, else (or while not backfilled) the numeric id."
        },
        "publicId": {
          "type": [
            "string",
            "null"
          ]
        },
        "path": {
          "type": [
            "string",
            "null"
          ]
        },
        "url": {
          "type": [
            "string",
            "null"
          ]
        },
        "displayName": {
          "type": "string"
        },
        "label": {
          "type": "string",
          "description": "What to show: displayName, or — when another product in the same result shares the display name — `displayName (<model code | part number | alias | publicId>)`, the first that tells them apart. Deterministic."
        },
        "modelCode": {
          "type": "string",
          "description": "The raw model string as published (e.g. `R8/17C PLUS`)."
        },
        "partNumber": {
          "type": [
            "string",
            "null"
          ],
          "description": "Manufacturer part number / SKU as published."
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Part-number aliases (superseded, regional, vendor alternatives), sorted."
        },
        "brand": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "slug": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          }
        },
        "series": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "name": {
              "type": "string"
            },
            "slug": {
              "type": "string"
            }
          }
        },
        "lifecycle": {
          "type": "string",
          "enum": [
            "active",
            "discontinued",
            "replaced",
            "unknown"
          ]
        },
        "speedBasis": {
          "type": "string",
          "enum": [
            "load",
            "no_load",
            "unknown"
          ]
        },
        "specs": {
          "type": "object",
          "description": "Key specs from the product's published values: torque_nm, rpm, diameter_mm when known.",
          "additionalProperties": {
            "$ref": "#/$defs/ReplacementSpecValue"
          }
        }
      }
    },
    "ReplacementSpecValue": {
      "type": "object",
      "properties": {
        "value": {
          "description": "Number, text or list of values.",
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": [
                  "string",
                  "number"
                ]
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "display": {
          "type": "string",
          "description": "Display text with unit; enum values as vocabulary labels (e.g. `8 Nm`, `Roller shutter, Awning`, `io-homecontrol`)."
        },
        "unit": {
          "type": [
            "string",
            "null"
          ]
        },
        "basis": {
          "type": "string",
          "enum": [
            "claim",
            "derived_model_name",
            "series_default",
            "user_override"
          ],
          "description": "claim = a product claim; derived_model_name = read from the model name (shown as 'from the model name'); series_default = a series-level value; user_override = a value the requester supplied (torque/rpm/diameter/voltage params, shown as 'your value')."
        },
        "basisLabel": {
          "type": [
            "string",
            "null"
          ]
        },
        "claimId": {
          "type": [
            "string",
            "null"
          ]
        },
        "qualifier": {
          "type": [
            "string",
            "null"
          ]
        },
        "evidenceStrength": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}