{
 "openapi": "3.0.3",
 "info": {
  "title": "Hublot",
  "version": "1.0.0",
  "description": "API des connexions aériennes : aéroports, compagnies, liaisons directes, saisonnalité et périodes d'exploitation. Chaque réponse contient les attributions obligatoires des sources utilisées."
 },
 "servers": [
  {
   "url": "https://hublot-api.akktis.dev"
  }
 ],
 "security": [
  {
   "cle": []
  }
 ],
 "components": {
  "securitySchemes": {
   "cle": {
    "type": "apiKey",
    "in": "header",
    "name": "X-Api-Key"
   }
  },
  "schemas": {
   "Airport": {
    "type": "object",
    "properties": {
     "iata": {
      "type": "string"
     },
     "icao": {
      "type": "string"
     },
     "nom": {
      "type": "string"
     },
     "ville": {
      "type": "string"
     },
     "pays": {
      "type": "string"
     },
     "lat": {
      "type": "number"
     },
     "lon": {
      "type": "number"
     },
     "fuseau_horaire": {
      "type": "string"
     }
    }
   },
   "Period": {
    "type": "object",
    "properties": {
     "debut": {
      "type": "string",
      "format": "date"
     },
     "fin": {
      "type": "string",
      "format": "date"
     },
     "type": {
      "type": "string",
      "enum": [
       "observe",
       "prevu"
      ]
     },
     "source": {
      "type": "string"
     },
     "en_cours": {
      "type": "boolean"
     },
     "vols": {
      "type": "integer",
      "nullable": true
     },
     "jours": {
      "type": "integer",
      "nullable": true,
      "description": "Jours de la semaine (bit 0 = lundi)."
     }
    }
   },
   "Destination": {
    "type": "object",
    "properties": {
     "iata": {
      "type": "string"
     },
     "ville": {
      "type": "string"
     },
     "pays": {
      "type": "string"
     },
     "lat": {
      "type": "number"
     },
     "lon": {
      "type": "number"
     },
     "km": {
      "type": "integer"
     },
     "statut": {
      "type": "string",
      "enum": [
       "reguliere",
       "saisonniere",
       "ancienne"
      ]
     },
     "saisonniere": {
      "type": "boolean"
     },
     "debut": {
      "type": "string",
      "format": "date",
      "nullable": true
     },
     "fin": {
      "type": "string",
      "format": "date",
      "nullable": true
     },
     "compagnies": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "iata": {
         "type": "string"
        },
        "icao": {
         "type": "string"
        },
        "nom": {
         "type": "string"
        },
        "periodes": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/Period"
         }
        },
        "wikipedia": {
         "type": "object",
         "nullable": true,
         "properties": {
          "saisonnier": {
           "type": "boolean"
          },
          "charter": {
           "type": "boolean"
          },
          "debut": {
           "type": "string"
          },
          "fin": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  }
 },
 "paths": {
  "/v1/sources": {
   "get": {
    "summary": "Sources et licences",
    "security": [],
    "responses": {
     "200": {
      "description": "Liste des sources"
     }
    }
   }
  },
  "/v1/meta": {
   "get": {
    "summary": "Dates des derniers relevés et sources de la clé",
    "responses": {
     "200": {
      "description": "Métadonnées",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "object"
          },
          "portee": {
           "type": "string",
           "enum": [
            "interne",
            "commercial"
           ]
          },
          "attributions": {
           "type": "array",
           "items": {
            "type": "string"
           }
          },
          "licence": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Clé manquante ou invalide"
     },
     "404": {
      "description": "Introuvable"
     }
    }
   }
  },
  "/v1/airports": {
   "get": {
    "summary": "Aéroports ayant des liaisons",
    "parameters": [
     {
      "name": "format",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "compact"
       ]
      },
      "description": "Tableaux au lieu d'objets (plus léger)."
     }
    ],
    "responses": {
     "200": {
      "description": "Aéroports",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "type": "object"
           }
          },
          "portee": {
           "type": "string",
           "enum": [
            "interne",
            "commercial"
           ]
          },
          "attributions": {
           "type": "array",
           "items": {
            "type": "string"
           }
          },
          "licence": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Clé manquante ou invalide"
     },
     "404": {
      "description": "Introuvable"
     }
    }
   }
  },
  "/v1/airports/{iata}": {
   "get": {
    "summary": "Fiche d'un aéroport",
    "parameters": [
     {
      "name": "iata",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[A-Z0-9]{3}$"
      },
      "example": "CDG"
     }
    ],
    "responses": {
     "200": {
      "description": "Aéroport",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/Airport"
          },
          "portee": {
           "type": "string",
           "enum": [
            "interne",
            "commercial"
           ]
          },
          "attributions": {
           "type": "array",
           "items": {
            "type": "string"
           }
          },
          "licence": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Clé manquante ou invalide"
     },
     "404": {
      "description": "Introuvable"
     }
    }
   }
  },
  "/v1/airports/{iata}/routes": {
   "get": {
    "summary": "Destinations directes depuis un aéroport",
    "parameters": [
     {
      "name": "iata",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[A-Z0-9]{3}$"
      },
      "example": "CDG"
     }
    ],
    "responses": {
     "200": {
      "description": "Destinations",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "object",
           "properties": {
            "origine": {
             "$ref": "#/components/schemas/Airport"
            },
            "destinations": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/Destination"
             }
            },
            "codes_inconnus": {
             "type": "array",
             "items": {
              "type": "string"
             }
            }
           }
          },
          "portee": {
           "type": "string",
           "enum": [
            "interne",
            "commercial"
           ]
          },
          "attributions": {
           "type": "array",
           "items": {
            "type": "string"
           }
          },
          "licence": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Clé manquante ou invalide"
     },
     "404": {
      "description": "Introuvable"
     }
    }
   }
  },
  "/v1/airlines": {
   "get": {
    "summary": "Compagnies ayant des liaisons",
    "parameters": [
     {
      "name": "format",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "compact"
       ]
      },
      "description": "Tableaux au lieu d'objets (plus léger)."
     }
    ],
    "responses": {
     "200": {
      "description": "Compagnies",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "type": "object"
           }
          },
          "portee": {
           "type": "string",
           "enum": [
            "interne",
            "commercial"
           ]
          },
          "attributions": {
           "type": "array",
           "items": {
            "type": "string"
           }
          },
          "licence": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Clé manquante ou invalide"
     },
     "404": {
      "description": "Introuvable"
     }
    }
   }
  },
  "/v1/airlines/{code}/network": {
   "get": {
    "summary": "Réseau d'une compagnie",
    "parameters": [
     {
      "name": "code",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "example": "V7"
     }
    ],
    "responses": {
     "200": {
      "description": "Réseau",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "object",
           "properties": {
            "compagnie": {
             "type": "object"
            },
            "aeroports": {
             "type": "object"
            },
            "liaisons": {
             "type": "array",
             "items": {
              "type": "array"
             },
             "description": "[iata_a, iata_b, statut]"
            }
           }
          },
          "portee": {
           "type": "string",
           "enum": [
            "interne",
            "commercial"
           ]
          },
          "attributions": {
           "type": "array",
           "items": {
            "type": "string"
           }
          },
          "licence": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Clé manquante ou invalide"
     },
     "404": {
      "description": "Introuvable"
     }
    }
   }
  }
 }
}