{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lexio-rent/json-schema/lexio-rent-inspection-schema.json",
  "title": "Inspection",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lexio-rent-openapi.json#/components/schemas/Inspection",
  "type": "object",
  "properties": {
    "phase": {
      "type": "string",
      "enum": [
        "DEPARTURE",
        "RETURN"
      ],
      "description": "État des lieux de départ ou de retour."
    },
    "inspectedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Instant de l’état des lieux, heure du loueur avec décalage."
    },
    "odometerKm": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0
        },
        {
          "type": "null"
        }
      ],
      "description": "null = non relevé (jamais 0 inventé)."
    },
    "fuelLevelPercent": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        {
          "type": "null"
        }
      ],
      "description": "Carburant ou charge selon l’énergie ; null = non relevé."
    },
    "checklist": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "interiorClean": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "OK",
                    "NOT_OK",
                    "NOT_CHECKED"
                  ]
                },
                {
                  "type": "null"
                }
              ],
              "description": "Propreté intérieure ; null : contrôle non applicable."
            },
            "exteriorClean": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "OK",
                    "NOT_OK",
                    "NOT_CHECKED"
                  ]
                },
                {
                  "type": "null"
                }
              ],
              "description": "Propreté extérieure ; null : contrôle non applicable."
            },
            "vehiclePapers": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "OK",
                    "NOT_OK",
                    "NOT_CHECKED"
                  ]
                },
                {
                  "type": "null"
                }
              ],
              "description": "Papiers du véhicule à bord ; null : contrôle non applicable."
            },
            "safetyKit": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "OK",
                    "NOT_OK",
                    "NOT_CHECKED"
                  ]
                },
                {
                  "type": "null"
                }
              ],
              "description": "Équipements de sécurité à bord ; null : contrôle non applicable."
            },
            "levels": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "OK",
                    "NOT_OK",
                    "NOT_CHECKED"
                  ]
                },
                {
                  "type": "null"
                }
              ],
              "description": "Niveaux ; null : contrôle non applicable."
            },
            "skippedViews": {
              "maxItems": 32,
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "FRONT",
                  "FRONT_LEFT",
                  "REAR_LEFT",
                  "REAR",
                  "REAR_RIGHT",
                  "FRONT_RIGHT",
                  "WINDSHIELD",
                  "INTERIOR",
                  "TRUNK",
                  "DASHBOARD",
                  "TW_FRONT",
                  "TW_COCKPIT",
                  "TW_LEFT",
                  "TW_RIGHT",
                  "TW_REAR",
                  "TW_SADDLE",
                  "WHEEL_FRONT_LEFT",
                  "DOOR_FRONT_LEFT",
                  "DOOR_REAR_LEFT",
                  "WHEEL_REAR_LEFT",
                  "WHEEL_REAR_RIGHT",
                  "DOOR_REAR_RIGHT",
                  "DOOR_FRONT_RIGHT",
                  "WHEEL_FRONT_RIGHT",
                  "REAR_SEATS"
                ],
                "description": "Voiture : vues sans préfixe TW_ ; deux-roues : vues TW_* ; DASHBOARD : les deux."
              },
              "description": "Vues du tour photo déclarées non photographiées."
            }
          },
          "required": [
            "interiorClean",
            "exteriorClean",
            "vehiclePapers",
            "safetyKit",
            "levels",
            "skippedViews"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "null = état des lieux sans contrôles structurés."
    },
    "damages": {
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              {
                "type": "null"
              }
            ],
            "description": "À citer dans confirmedDepartureDamageIds au retour ; null = dommage historique non identifié, qui ne peut pas être confirmé."
          },
          "type": {
            "type": "string",
            "enum": [
              "SCRATCH",
              "DENT",
              "CRACK",
              "BROKEN",
              "STAIN",
              "OTHER"
            ],
            "description": "Nature du dommage."
          },
          "view": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "FRONT",
                  "FRONT_LEFT",
                  "REAR_LEFT",
                  "REAR",
                  "REAR_RIGHT",
                  "FRONT_RIGHT",
                  "WINDSHIELD",
                  "INTERIOR",
                  "TRUNK",
                  "DASHBOARD",
                  "TW_FRONT",
                  "TW_COCKPIT",
                  "TW_LEFT",
                  "TW_RIGHT",
                  "TW_REAR",
                  "TW_SADDLE",
                  "WHEEL_FRONT_LEFT",
                  "DOOR_FRONT_LEFT",
                  "DOOR_REAR_LEFT",
                  "WHEEL_REAR_LEFT",
                  "WHEEL_REAR_RIGHT",
                  "DOOR_REAR_RIGHT",
                  "DOOR_FRONT_RIGHT",
                  "WHEEL_FRONT_RIGHT",
                  "REAR_SEATS"
                ],
                "description": "Voiture : vues sans préfixe TW_ ; deux-roues : vues TW_* ; DASHBOARD : les deux."
              },
              {
                "type": "null"
              }
            ],
            "description": "null = dommage historique en texte libre ; type vaut alors OTHER."
          },
          "description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "description": "Description libre ; null si absente."
          }
        },
        "required": [
          "id",
          "type",
          "view",
          "description"
        ]
      },
      "description": "DEPARTURE : dommages constatés au départ. RETURN : nouveaux dommages."
    },
    "confirmedDepartureDamageIds": {
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64
      },
      "description": "RETURN : dommages du départ confirmés. Toujours [] en DEPARTURE."
    },
    "notes": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ],
      "description": "Remarques libres ; null si absentes."
    },
    "isSigned": {
      "type": "boolean",
      "description": "true : signé par le client ; l’image de la signature n’est jamais exposée."
    },
    "signatureWaivedReason": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 300
        },
        {
          "type": "null"
        }
      ],
      "description": "RETURN sans le client : motif de la levée de signature."
    }
  },
  "required": [
    "phase",
    "inspectedAt",
    "odometerKm",
    "fuelLevelPercent",
    "checklist",
    "damages",
    "confirmedDepartureDamageIds",
    "notes",
    "isSigned",
    "signatureWaivedReason"
  ]
}