{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/farmos/json-schema/farmos-quantity-request-schema.json",
  "title": "QuantityRequest",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/farmos-quantities-api-openapi.yml#/components/schemas/QuantityRequest",
  "type": "object",
  "required": [
    "data"
  ],
  "properties": {
    "data": {
      "$ref": "#/$defs/QuantityData"
    }
  },
  "$defs": {
    "JsonApiLinks": {
      "type": "object",
      "properties": {
        "self": {
          "type": "string",
          "format": "uri"
        },
        "related": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "JsonApiRelationship": {
      "type": "object",
      "properties": {
        "data": {
          "oneOf": [
            {
              "$ref": "#/$defs/JsonApiRelationshipData"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/JsonApiRelationshipData"
              }
            },
            {
              "type": [
                "object",
                "null"
              ],
              "maxProperties": 0
            }
          ]
        },
        "links": {
          "$ref": "#/$defs/JsonApiLinks"
        }
      }
    },
    "JsonApiRelationshipData": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        },
        "id": {
          "type": "string",
          "format": "uuid"
        }
      }
    },
    "QuantityAttributes": {
      "type": "object",
      "properties": {
        "measure": {
          "type": "string",
          "description": "Type of measurement (e.g., weight, volume, count, length, area, time, temperature, pressure, water_content, rating, ratio)",
          "enum": [
            "weight",
            "volume",
            "count",
            "length",
            "area",
            "time",
            "temperature",
            "pressure",
            "water_content",
            "rating",
            "ratio"
          ]
        },
        "value": {
          "type": "object",
          "description": "Numeric value with decimal precision",
          "properties": {
            "numerator": {
              "type": "integer"
            },
            "denominator": {
              "type": "integer"
            },
            "decimal": {
              "type": "string"
            }
          }
        },
        "label": {
          "type": "string",
          "description": "Optional label for the quantity"
        },
        "inventory_adjustment": {
          "type": "string",
          "description": "How this quantity affects inventory (increment or decrement)",
          "enum": [
            "increment",
            "decrement",
            "reset"
          ]
        }
      }
    },
    "QuantityData": {
      "type": "object",
      "required": [
        "type",
        "attributes"
      ],
      "properties": {
        "type": {
          "type": "string"
        },
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "attributes": {
          "$ref": "#/$defs/QuantityAttributes"
        },
        "relationships": {
          "$ref": "#/$defs/QuantityRelationships"
        },
        "links": {
          "$ref": "#/$defs/JsonApiLinks"
        }
      }
    },
    "QuantityRelationships": {
      "type": "object",
      "properties": {
        "units": {
          "$ref": "#/$defs/JsonApiRelationship"
        },
        "inventory_asset": {
          "$ref": "#/$defs/JsonApiRelationship"
        }
      }
    }
  }
}