{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/craftquantities-com/json-schema/craftquantities-com-calculate-result-schema.json",
  "title": "CalculateResult",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/trades/craftquantities-com-auto-utility.json#/components/schemas/CalculateResult",
  "type": "object",
  "required": [
    "engine",
    "calculator",
    "system",
    "inputs",
    "result",
    "sources",
    "citation",
    "links",
    "licence",
    "notice"
  ],
  "properties": {
    "engine": {
      "type": "object",
      "required": [
        "name",
        "version",
        "api"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "api": {
          "type": "string"
        }
      }
    },
    "calculator": {
      "type": "object",
      "required": [
        "slug",
        "title",
        "category",
        "version",
        "lastVerified",
        "url",
        "json"
      ],
      "properties": {
        "slug": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "category": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "version": {
          "type": "string",
          "description": "The calculator's own version; a result names the calculator that produced it."
        },
        "lastVerified": {
          "type": "string",
          "description": "The date the calculator's sources were last checked."
        },
        "url": {
          "type": "string",
          "description": "The calculator's page on craftquantities.com."
        },
        "json": {
          "type": "string",
          "description": "The calculator's static API document, with its test vectors."
        }
      }
    },
    "system": {
      "enum": [
        "metric",
        "imperial"
      ]
    },
    "market": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "inputs": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "type",
          "value",
          "source"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "type": {
            "enum": [
              "number",
              "select"
            ]
          },
          "value": {
            "type": [
              "number",
              "string"
            ]
          },
          "dimension": {
            "type": "string"
          },
          "baseUnit": {
            "type": "string"
          },
          "source": {
            "enum": [
              "caller",
              "default"
            ]
          },
          "read": {
            "type": "string"
          },
          "metric": {
            "type": "object",
            "required": [
              "value",
              "unit"
            ],
            "properties": {
              "value": {
                "type": "number"
              },
              "unit": {
                "type": "string"
              }
            }
          },
          "imperial": {
            "type": "object",
            "required": [
              "value",
              "unit"
            ],
            "properties": {
              "value": {
                "type": "number"
              },
              "unit": {
                "type": "string"
              }
            }
          },
          "option": {
            "type": "string"
          }
        }
      },
      "description": "Every input the calculation ran on, and where each came from."
    },
    "result": {
      "type": "object",
      "required": [
        "label",
        "metric",
        "imperial"
      ],
      "properties": {
        "label": {
          "type": "string"
        },
        "metric": {
          "type": "object",
          "required": [
            "value",
            "unit",
            "printed",
            "breakdown",
            "confidence",
            "isComparison",
            "canonical"
          ],
          "properties": {
            "value": {
              "anyOf": [
                {
                  "type": "number",
                  "description": "The headline in this system; null where a rate it needs is not given."
                },
                {
                  "type": "null"
                }
              ]
            },
            "unit": {
              "type": "string"
            },
            "printed": {
              "anyOf": [
                {
                  "type": "string",
                  "description": "The headline exactly as the page prints it."
                },
                {
                  "type": "null"
                }
              ]
            },
            "breakdown": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "label",
                  "value",
                  "unit",
                  "printed"
                ],
                "properties": {
                  "label": {
                    "type": "string"
                  },
                  "value": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "unit": {
                    "type": "string"
                  },
                  "printed": {
                    "type": "string"
                  }
                }
              }
            },
            "confidence": {
              "enum": [
                "high",
                "medium",
                "low"
              ]
            },
            "confidenceNote": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "allowance": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "percent": {
                      "type": "number"
                    },
                    "base": {
                      "type": "number"
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "limitations": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "isComparison": {
              "type": "boolean",
              "description": "The figure is set against a limit. It is not an approval."
            },
            "withheld": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "missingRates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "input": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "canonical": {
              "type": "object",
              "required": [
                "value",
                "unit"
              ],
              "properties": {
                "value": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "unit": {
                  "type": "string"
                }
              },
              "description": "The figure in the calculator's own unit, before the display adapter: what its test vectors pin."
            }
          }
        },
        "imperial": {
          "type": "object",
          "required": [
            "value",
            "unit",
            "printed",
            "breakdown",
            "confidence",
            "isComparison",
            "canonical"
          ],
          "properties": {
            "value": {
              "anyOf": [
                {
                  "type": "number",
                  "description": "The headline in this system; null where a rate it needs is not given."
                },
                {
                  "type": "null"
                }
              ]
            },
            "unit": {
              "type": "string"
            },
            "printed": {
              "anyOf": [
                {
                  "type": "string",
                  "description": "The headline exactly as the page prints it."
                },
                {
                  "type": "null"
                }
              ]
            },
            "breakdown": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "label",
                  "value",
                  "unit",
                  "printed"
                ],
                "properties": {
                  "label": {
                    "type": "string"
                  },
                  "value": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "unit": {
                    "type": "string"
                  },
                  "printed": {
                    "type": "string"
                  }
                }
              }
            },
            "confidence": {
              "enum": [
                "high",
                "medium",
                "low"
              ]
            },
            "confidenceNote": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "allowance": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "percent": {
                      "type": "number"
                    },
                    "base": {
                      "type": "number"
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "limitations": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "isComparison": {
              "type": "boolean",
              "description": "The figure is set against a limit. It is not an approval."
            },
            "withheld": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "missingRates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "input": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "canonical": {
              "type": "object",
              "required": [
                "value",
                "unit"
              ],
              "properties": {
                "value": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "unit": {
                  "type": "string"
                }
              },
              "description": "The figure in the calculator's own unit, before the display adapter: what its test vectors pin."
            }
          }
        }
      }
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "label"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "The source as the calculator cites it."
          },
          "url": {
            "type": "string",
            "description": "Only where the calculator gives one; none is invented."
          },
          "references": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "kind",
                "document"
              ],
              "properties": {
                "kind": {
                  "enum": [
                    "code",
                    "standard"
                  ]
                },
                "body": {
                  "type": "string"
                },
                "document": {
                  "type": "string"
                },
                "section": {
                  "type": "string"
                },
                "edition": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "citation": {
      "type": "object",
      "required": [
        "author",
        "title",
        "url",
        "formats",
        "accessDate"
      ],
      "properties": {
        "author": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "version": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "sourcesChecked": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "url": {
          "type": "string"
        },
        "accessDate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "formats": {
          "type": "object",
          "required": [
            "plain",
            "apa",
            "harvard",
            "bibtex"
          ],
          "properties": {
            "plain": {
              "type": "string"
            },
            "apa": {
              "type": "string"
            },
            "harvard": {
              "type": "string"
            },
            "bibtex": {
              "type": "string"
            }
          }
        }
      }
    },
    "links": {
      "type": "object",
      "required": [
        "page",
        "open"
      ],
      "properties": {
        "page": {
          "type": "string"
        },
        "open": {
          "type": "string",
          "description": "Opens the page on these inputs."
        }
      }
    },
    "licence": {
      "type": "object",
      "required": [
        "name",
        "url",
        "attribution"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "attribution": {
          "type": "string"
        }
      }
    },
    "notice": {
      "type": "string"
    },
    "explain": {
      "type": "object",
      "required": [
        "about",
        "coverage",
        "steps",
        "final",
        "limits"
      ],
      "description": "Only when explain is true. Each figure is the calculator's own; no step is a formula written for the engine.",
      "properties": {
        "about": {
          "type": "string"
        },
        "coverage": {
          "enum": [
            "intermediates",
            "result-only"
          ],
          "description": "result-only: the calculator reports no figures between its inputs and its result."
        },
        "steps": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "n",
              "kind",
              "system",
              "label",
              "text"
            ],
            "properties": {
              "n": {
                "type": "integer"
              },
              "kind": {
                "enum": [
                  "input",
                  "intermediate",
                  "result",
                  "allowance",
                  "range",
                  "rates",
                  "display"
                ]
              },
              "system": {
                "enum": [
                  "metric",
                  "imperial",
                  "both"
                ]
              },
              "label": {
                "type": "string"
              },
              "value": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "unit": {
                "type": "string",
                "description": "The calculator's own (base) unit for the value."
              },
              "metric": {
                "type": "object",
                "required": [
                  "value",
                  "unit"
                ],
                "properties": {
                  "value": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "unit": {
                    "type": "string"
                  }
                }
              },
              "imperial": {
                "type": "object",
                "required": [
                  "value",
                  "unit"
                ],
                "properties": {
                  "value": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "unit": {
                    "type": "string"
                  }
                }
              },
              "movedBy": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Input ids whose change moved this figure, measured by running compute again."
              },
              "source": {
                "enum": [
                  "caller",
                  "default"
                ]
              },
              "text": {
                "type": "string",
                "description": "The step in words."
              }
            }
          }
        },
        "final": {
          "type": "object",
          "required": [
            "metric",
            "imperial"
          ],
          "properties": {
            "metric": {
              "type": "object",
              "required": [
                "value",
                "unit",
                "printed"
              ],
              "properties": {
                "value": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "unit": {
                  "type": "string"
                },
                "printed": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            },
            "imperial": {
              "type": "object",
              "required": [
                "value",
                "unit",
                "printed"
              ],
              "properties": {
                "value": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "unit": {
                  "type": "string"
                },
                "printed": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "description": "The figures the answer returns, copied from it."
        },
        "limits": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "What the trace does not show, and why."
        }
      }
    }
  }
}