{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/transit/json-schema/transit-simple-leg-schema.json",
  "title": "SimpleLeg",
  "description": "Simple leg, used for walk for personal_bike legs",
  "x-generated": "2026-12-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/transit-v4-api-openapi.yml#/components/schemas/SimpleLeg",
  "type": "object",
  "properties": {
    "leg_mode": {
      "type": "string",
      "enum": [
        "walk",
        "personal_bike"
      ],
      "description": "The mode of the current leg. In simple legs, it can be either walk or personal_bike."
    },
    "start_time": {
      "type": "integer",
      "description": "The expected start time in unix time"
    },
    "end_time": {
      "type": "integer",
      "description": "The expected end time in unix time"
    },
    "duration": {
      "type": "integer",
      "description": "Travel duration in seconds"
    },
    "distance": {
      "type": "number",
      "format": "double",
      "description": "Total distance traveled of the leg, in meters"
    },
    "safety_analysis": {
      "type": "object",
      "description": "Breakdown of the leg's distance by bike infrastructure safety. Only present for personal_bike legs, and only when should_include_safety is set to true.",
      "properties": {
        "protected_lanes_percentage": {
          "type": "number",
          "format": "double",
          "description": "Percentage (0-100) of the leg traveled on physically protected bike lanes."
        },
        "lanes_percentage": {
          "type": "number",
          "format": "double",
          "description": "Percentage (0-100) of the leg traveled on any kind of bike lane (protected, unprotected, or opposite-direction)."
        },
        "safe_percentage": {
          "type": "number",
          "format": "double",
          "description": "Percentage (0-100) of the leg traveled on bike lanes or low-traffic residential roads."
        },
        "segments": {
          "type": "array",
          "description": "The consecutive stretches of way the leg travels, in travel order, each with the bike infrastructure it offers. This is the per-segment detail the percentages above summarize, and it matches the styling used for bike paths on Transit's map, so a route drawn from these segments looks like the one shown in the app. Their lengths sum to the leg's `distance` and their polylines join end to end to form the leg's `polyline`. Note this is a different segmentation than `directions`, which has one entry per turn and can therefore span several segments.",
          "items": {
            "type": "object",
            "properties": {
              "way_name": {
                "type": "string",
                "description": "the name of the way this segment follows."
              },
              "protection": {
                "type": "string",
                "description": "Bike infrastructure classification of this segment.\n * `protected_lane` - physically separated from traffic.\n * `lane` - painted, shared, contraflow or shared-bus lane.\n * `warning` - mixed with car traffic, no bike infrastructure.\n * `walk` - bikes not permitted, the rider must dismount.\n * `default` - bike-accessible way with no specific infrastructure.",
                "enum": [
                  "default",
                  "lane",
                  "protected_lane",
                  "warning",
                  "walk"
                ]
              },
              "length": {
                "type": "number",
                "format": "double",
                "description": "the segment length in meters"
              },
              "polyline": {
                "type": "string",
                "description": "Shape of the segment provided in the [encoded polyline format](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)."
              }
            }
          }
        }
      }
    },
    "directions": {
      "type": "array",
      "description": "Directions are only available if should_include_directions is set to true. They give precise information on the steps to follow for this leg.",
      "items": {
        "type": "object",
        "description": "each object is a step, containing an instruction and some data about it.",
        "properties": {
          "length": {
            "type": "number",
            "format": "double",
            "description": "the step length in meters"
          },
          "way_name": {
            "type": "string",
            "description": "the name of the way we are currently on."
          },
          "duration": {
            "type": "number",
            "format": "double",
            "description": "the step duration in seconds"
          },
          "angle": {
            "type": "number",
            "format": "double",
            "description": "the angle to continue to the next instruction in degrees."
          },
          "instruction": {
            "type": "string",
            "description": "the detailed instruction to be displayed to the user."
          },
          "polyline": {
            "type": "string",
            "description": "Shape of the step provided in the [encoded polyline format](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)."
          },
          "entrance": {
            "type": "object",
            "description": "Details about the entrance when entering a transit station (optional).",
            "properties": {
              "stop_name": {
                "type": "string",
                "description": "The name of the entrance."
              },
              "raw_stop_id": {
                "type": "string",
                "description": "The GTFS stop_id of the entrance."
              },
              "stop_code": {
                "type": "string",
                "description": "The GTFS stop_code of the entrance."
              }
            }
          },
          "exit": {
            "type": "object",
            "description": "Details about the exit when leaving a transit station (optional).",
            "properties": {
              "stop_name": {
                "type": "string",
                "description": "The name of the exit."
              },
              "raw_stop_id": {
                "type": "string",
                "description": "The GTFS stop_id of the exit."
              },
              "stop_code": {
                "type": "string",
                "description": "The GTFS stop_code of the exit."
              }
            }
          },
          "pathway_mode": {
            "type": "string",
            "description": "The GTFS pathway mode for this step (e.g. WALKWAY, STAIRS, ESCALATOR, ELEVATOR, FARE_GATE, EXIT_GATE, MOVING_SIDEWALK). Only present when should_include_pathways is true and the step is part of a station pathway."
          }
        }
      }
    },
    "polyline": {
      "type": "string",
      "description": "Shape of the traveled path provided in the [encoded polyline format](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)."
    }
  },
  "required": [
    "leg_mode",
    "start_time",
    "end_time",
    "duration",
    "distance",
    "polyline"
  ]
}