{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://quadruper.invalid/contracts/geoapi-nearby-response.v1.schema.json",
  "title": "NearbyResponse",
  "description": "GET /v2/nearby 200 body. Nearest first; an empty results array is a normal answer.",
  "type": "object",
  "properties": {
    "results": { "type": "array", "maxItems": 60, "items": { "$ref": "#/$defs/nearbyPlace" } },
    "attribution": { "$ref": "geoapi-common.v1.schema.json#/$defs/attribution" }
  },
  "required": ["results", "attribution"],
  "additionalProperties": false,
  "$defs": {
    "nearbyPlace": {
      "title": "NearbyPlace",
      "description": "A common place plus its distance from the query point.",
      "type": "object",
      "properties": {
        "source": { "enum": ["osm", "local", "overture"] },
        "id": {
          "oneOf": [
            { "type": "string", "pattern": "^[A-Za-z0-9/_-]{1,80}$" },
            { "type": "null" }
          ]
        },
        "name": { "$ref": "geoapi-common.v1.schema.json#/$defs/nullableString" },
        "label": { "type": "string", "minLength": 1 },
        "location": { "$ref": "geoapi-common.v1.schema.json#/$defs/lnglat" },
        "category": { "$ref": "geoapi-common.v1.schema.json#/$defs/nullableString" },
        "type": { "$ref": "geoapi-common.v1.schema.json#/$defs/nullableString" },
        "address": { "$ref": "geoapi-common.v1.schema.json#/$defs/address" },
        "distance_m": { "type": "integer", "minimum": 0, "maximum": 5000 }
      },
      "required": ["source", "id", "name", "label", "location", "category", "type", "address", "distance_m"],
      "additionalProperties": false
    }
  }
}
