{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schema.govfresh.com/v1/requests/service.schema.json",
  "title": "Service",
  "description": "One service a resident can request, and the questions asked when requesting it.",
  "standards": [
    "open311-georeport-v2"
  ],
  "type": "object",
  "properties": {
    "@context": {},
    "@id": {
      "type": "string",
      "format": "iri",
      "description": "This service's own dereferenceable identifier."
    },
    "@type": {
      "const": "GovernmentService",
      "description": "Always `GovernmentService` - this is the half of Open311 that schema.org does cover: `GovernmentService` is a real type, `ServiceChannel` describes how to reach it, and `PropertyValueSpecification` describes a form field, so the request attributes need no minted vocabulary. Combines the Open311 Service List and Service Definition into a single entity."
    },
    "name": {
      "type": "string",
      "description": "The service's public name, e.g. 'Pothole Repair'."
    },
    "description": {
      "type": "string",
      "description": "A plain-language explanation of the service, shown to residents deciding what to report."
    },
    "url": {
      "type": "string",
      "format": "iri",
      "description": "Where more information about this service can be found."
    },
    "serviceCode": {
      "type": "string",
      "description": "Open311 `service_code`. Stable; requests reference it."
    },
    "serviceType": {
      "type": "string",
      "description": "Open311 `group`, e.g. 'Streets', 'Sanitation'."
    },
    "keywords": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Search terms residents might use to find this service."
    },
    "provider": {
      "$ref": "../_core/reference.schema.json",
      "description": "The `GovernmentOrganization` providing it."
    },
    "areaServed": {
      "$ref": "../_core/reference.schema.json",
      "description": "The `Jurisdiction` it covers."
    },
    "availableChannel": {
      "type": "array",
      "description": "schema.org `ServiceChannel`: how a resident actually reports this. `processingTime` carries the service-level expectation.",
      "items": {
        "type": "object",
        "properties": {
          "@type": {
            "const": "ServiceChannel"
          },
          "serviceUrl": {
            "type": "string",
            "format": "iri"
          },
          "servicePhone": {
            "type": "object"
          },
          "serviceSmsNumber": {
            "type": "object"
          },
          "serviceLocation": {
            "$ref": "../_core/reference.schema.json"
          },
          "processingTime": {
            "type": "string",
            "description": "ISO 8601 duration, e.g. P3D."
          },
          "availableLanguage": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "@type"
        ]
      }
    },
    "requestAttribute": {
      "type": "array",
      "description": "The questions asked when submitting. Open311 Service Definition attributes, as schema.org `PropertyValueSpecification`.",
      "items": {
        "type": "object",
        "properties": {
          "@type": {
            "const": "PropertyValueSpecification"
          },
          "valueName": {
            "type": "string",
            "description": "The attribute key. Open311 code."
          },
          "name": {
            "type": "string",
            "description": "The question shown to the resident. Open311 description."
          },
          "valueRequired": {
            "type": "boolean"
          },
          "multipleValues": {
            "type": "boolean",
            "description": "True for Open311 multivaluelist."
          },
          "defaultValue": {
            "type": "string"
          },
          "valueMinLength": {
            "type": "number"
          },
          "valueMaxLength": {
            "type": "number"
          },
          "valuePattern": {
            "type": "string"
          },
          "minValue": {
            "type": "number"
          },
          "maxValue": {
            "type": "number"
          },
          "position": {
            "type": "integer",
            "description": "Open311 order."
          },
          "valueOption": {
            "type": "array",
            "description": "Permitted values for a list attribute. Open311 values[].",
            "items": {
              "type": "object",
              "properties": {
                "@type": {
                  "const": "DefinedTerm"
                },
                "termCode": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "@type",
                "termCode"
              ]
            }
          }
        },
        "required": [
          "@type",
          "valueName"
        ]
      }
    },
    "isRealtime": {
      "type": "boolean",
      "description": "Whether a request against this service returns an id immediately. Open311 `type`: `realtime` versus `batch` or `blackbox`."
    },
    "sourceDataset": {
      "type": "string",
      "format": "iri",
      "description": "The `Dataset` this record was published as part of."
    }
  },
  "required": [
    "@id",
    "@type",
    "name",
    "serviceCode",
    "provider"
  ],
  "additionalProperties": true
}
