openapi: 3.1.1
info:
  title: Retail — Grocery Resource Attributes (v2.1)
  version: 2.1.0
  description: >
    Grocery-specific resource attributes for packaged foods and fresh produce.
    Migrated from GroceryItem (v2) to the v2.1 generalised model.
    Extends RetailResource via allOf to add nutrition and fresh produce properties.
    Attaches to beckn:Resource via resourceAttributes.

components:
  schemas:
    GroceryResource:
      type: object
      x-beckn-container: resourceAttributes
      x-jsonld:
        "@context": "https://schema.nfh.global/GroceryResource/v2.1/context.jsonld"
        "@type": groc:GroceryResource
      allOf:
        - $ref: "../../RetailResource/v2.1/attributes.yaml#/components/schemas/RetailResource"
        - type: object
          properties:
            nutrition:
              type: array
              items:
                type: object
                required: [nutrient, value]
                properties:
                  nutrient:
                    type: string
                    description: Name of the nutrient (e.g., Energy, Protein, Carbohydrates, Fat, Fiber, Sodium)
                    x-jsonld-id: "groc:nutrient"
                  value:
                    allOf:
                      - $ref: "https://schema.nfh.global/Quantity/v2.0/attributes.yaml#/components/schemas/Quantity"
                    description: Nutrient value using Beckn core Quantity (unitQuantity, unitCode per 100g or serving)
                    x-jsonld-id: "groc:nutritionValue"
              description: Array of nutrition facts (per 100g or serving size)
              x-jsonld-id: "groc:nutrition"
            freshProduce:
              type: object
              properties:
                netQuantityDeclaration:
                  type: string
                  description: Net quantity declaration for fresh produce (e.g., "1 kg", "500g", "5 units")
                  x-jsonld-id: "groc:netQuantityDeclaration"
                harvestDate:
                  type: string
                  format: date
                  description: >
                    Date the produce was harvested (ISO 8601 date, e.g., "2024-10-15").
                    Useful for freshness signalling on produce where no formal expiry label exists.
                  x-jsonld-id: "groc:harvestDate"
              description: Fresh produce-specific attributes (harvested, bulk items without standard packaging)
              x-jsonld-id: "groc:freshProduce"
