{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://postflight.co/aeronautiql/planning/v1_1/results/terminal-pressure.schema.json",
  "title": "Native terminal pressure retained at the converged trajectory clock",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "policyRevision": {
      "const": "arrival-pressure-v1"
    },
    "iterations": {
      "type": "integer",
      "minimum": 1,
      "maximum": 8
    },
    "departure": {
      "$ref": "#/$defs/endpoint"
    },
    "arrival": {
      "$ref": "#/$defs/endpoint"
    }
  },
  "required": [
    "policyRevision",
    "iterations",
    "departure",
    "arrival"
  ],
  "$defs": {
    "endpoint": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "stopId": {
          "type": "string",
          "minLength": 1
        },
        "request": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "schema_version": {
              "const": 1
            },
            "terminal_id": {
              "type": "string",
              "minLength": 1
            },
            "lat": {
              "type": "number",
              "minimum": -90,
              "maximum": 90
            },
            "lon": {
              "type": "number",
              "minimum": -180,
              "maximum": 180
            },
            "time_unix": {
              "type": "number"
            },
            "geometric_field_elevation_ft_msl": {
              "type": "number"
            },
            "source": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "mode": {
                  "enum": [
                    "gfs_only",
                    "auto"
                  ]
                },
                "expected_gfs_cycle": {
                  "type": "string",
                  "minLength": 1
                },
                "expected_hrrr_cycle": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "mode"
              ]
            },
            "weather_policy": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "version": {
                  "const": 1
                },
                "sources": {
                  "type": "array",
                  "minItems": 1,
                  "uniqueItems": true,
                  "items": {
                    "enum": [
                      "forecast",
                      "climatology",
                      "standard_atmosphere"
                    ]
                  }
                },
                "climatology_month": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 12
                },
                "planned_departure_unix": {
                  "type": "number"
                },
                "weather_intent": {
                  "enum": [
                    "entered_departure",
                    "current_weather_for_past_etd"
                  ]
                }
              },
              "required": [
                "version",
                "sources"
              ]
            }
          },
          "required": [
            "schema_version",
            "terminal_id",
            "lat",
            "lon",
            "time_unix",
            "geometric_field_elevation_ft_msl",
            "source"
          ]
        },
        "result": {
          "type": "object",
          "additionalProperties": true,
          "properties": {
            "schema_version": {
              "const": 1
            },
            "terminal_id": {
              "type": "string",
              "minLength": 1
            },
            "lat": {
              "type": "number",
              "minimum": -90,
              "maximum": 90
            },
            "lon": {
              "type": "number",
              "minimum": -180,
              "maximum": 180
            },
            "time_unix": {
              "type": "number"
            },
            "geometric_field_elevation_ft_msl": {
              "type": "number"
            },
            "status": {
              "const": "valid"
            },
            "pressure_altitude_ft": {
              "type": "number"
            },
            "field_pressure_hpa": {
              "type": "number",
              "exclusiveMinimum": 0
            },
            "source": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "model": {
                  "enum": [
                    "gfs",
                    "hrrr",
                    "standard_atmosphere"
                  ]
                },
                "cycle": {
                  "type": "string",
                  "minLength": 1
                },
                "valid_from_unix": {
                  "type": "number"
                },
                "valid_through_unix": {
                  "type": "number"
                },
                "quality": {
                  "enum": [
                    "surface_reference",
                    "terrain_adjusted_surface_reference",
                    "standard_atmosphere_estimate"
                  ]
                },
                "terminal_id": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "model",
                "cycle",
                "valid_from_unix",
                "valid_through_unix",
                "quality"
              ]
            }
          },
          "required": [
            "schema_version",
            "terminal_id",
            "lat",
            "lon",
            "time_unix",
            "geometric_field_elevation_ft_msl",
            "status",
            "pressure_altitude_ft",
            "field_pressure_hpa",
            "source"
          ]
        }
      },
      "required": [
        "stopId",
        "request",
        "result"
      ]
    }
  }
}
