{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mashprime-dev/json-schema/mashprime-dev-search-results-schema.json",
  "title": "SearchResults",
  "description": "Search results.",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mashprime-dev-openapi.json#/components/schemas/SearchResults",
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "description": "The query as received (trimmed)."
    },
    "count": {
      "type": "integer",
      "description": "Number of results returned.",
      "minimum": 0
    },
    "total": {
      "type": "integer",
      "description": "Number of matches before limit.",
      "minimum": 0
    },
    "results": {
      "type": "array",
      "description": "Matching posts, best match first.",
      "items": {
        "$ref": "#/$defs/SearchResult"
      }
    }
  },
  "required": [
    "query",
    "count",
    "total",
    "results"
  ],
  "additionalProperties": false,
  "$defs": {
    "SearchResult": {
      "type": "object",
      "description": "A post that matched the search, with a snippet around the match.",
      "properties": {
        "slug": {
          "type": "string",
          "description": "URL-safe identifier; use with GET /api/v1/posts/{slug}.",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "title": {
          "type": "string",
          "description": "Post title."
        },
        "description": {
          "type": "string",
          "description": "One- or two-sentence summary of the post."
        },
        "date": {
          "type": "string",
          "description": "Publication date (YYYY-MM-DD).",
          "format": "date"
        },
        "url": {
          "type": "string",
          "description": "Canonical HTML URL of the post.",
          "format": "uri"
        },
        "markdown_url": {
          "type": "string",
          "description": "URL of the post's raw markdown.",
          "format": "uri"
        },
        "snippet": {
          "type": "string",
          "description": "Text around the first match, or the description when the title/description matched."
        }
      },
      "required": [
        "slug",
        "title",
        "description",
        "date",
        "url",
        "markdown_url",
        "snippet"
      ],
      "additionalProperties": false
    }
  }
}