suggestions-questions-brainstorming icon indicating copy to clipboard operation
suggestions-questions-brainstorming copied to clipboard

Any way to optionally provide a more-specific type?

Open jyasskin opened this issue 1 year ago • 0 comments

The https://schema.org/recipeIngredient property refines supply to require the content to be Text. But ingredients have structure, which I'd like to expose to consumers that can understand it, so they can scale amounts if they want to. Is there a way in schema.org markup to indicate that one value is a refined version of another value?

For example:

{
  "@context": "http://schema.org",
  "type": "Recipe",
  "recipeIngredient": {
    "type": "HowToSupply",
    "requiredQuantity": {
      "type": "QuantitativeValue",
      "value": "1/4",
      "unitText": "tsp"
    },
    "name": "sugar"
  }
}

fails to validate.

{
  "@context": "http://schema.org",
  "type": "Recipe",
  "recipeIngredient": [{
    "type": "HowToSupply",
    "requiredQuantity": {
      "type": "QuantitativeValue",
      "value": "1/4",
      "unitText": "tsp"
    },
    "name": "sugar"
  }, "1/4 tsp sugar"]
}

will give the right content to processors that don't understand the HowToSupply type, but the ingredient will be duplicated for any that do understand it.

rdf:Alt seems like the standard way to encode this, but

{
  "@context": "https://schema.org",
  "type": "Recipe",
  "recipeIngredient": {
    "type": "rdf:Alt",
    "rdf:_1": {
      "type": "HowToSupply",
      "requiredQuantity": {
        "type": "QuantitativeValue",
        "value": " 1/4 ",
        "unitText": "tsp"
      },
      "name": " egg whites "
    },
    "rdf:_2": "1/4 tsp egg whites"
  }
}

also fails to validate.

jyasskin avatar Dec 21 '23 12:12 jyasskin