{
    "openapi": "3.0.1",
    "info": {
        "title": "Tâches",
        "version": "1.0",
        "description": "API RESTful de démonstration KoakDesign : lecture libre, écriture avec le jeton « Bearer demo-koakdesign »."
    },
    "servers": [
        {
            "url": "https://www.koakdesign.info/ws_demo/taches.php"
        }
    ],
    "tags": [
        {
            "name": "Tâches",
            "description": "Créer, lire, modifier, supprimer"
        },
        {
            "name": "Outils"
        }
    ],
    "paths": {
        "/taches": {
            "get": {
                "tags": [
                    "Tâches"
                ],
                "summary": "Lister les tâches",
                "parameters": [
                    {
                        "name": "fait",
                        "in": "query",
                        "description": "true : terminées, false : à faire",
                        "schema": {
                            "type": "boolean"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "La liste",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/Tache"
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "Tâches"
                ],
                "summary": "Créer une tâche",
                "security": [
                    {
                        "Jeton": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/NouvelleTache"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Créée",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Tache"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/taches/{id}": {
            "get": {
                "tags": [
                    "Tâches"
                ],
                "summary": "Lire une tâche",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "Numéro de la tâche",
                        "schema": {
                            "type": "integer",
                            "example": 2
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "La tâche",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Tache"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "tags": [
                    "Tâches"
                ],
                "summary": "Remplacer une tâche",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "Numéro de la tâche",
                        "schema": {
                            "type": "integer",
                            "example": 2
                        }
                    }
                ],
                "security": [
                    {
                        "Jeton": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/NouvelleTache"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Remplacée",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Tache"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "tags": [
                    "Tâches"
                ],
                "summary": "Modifier une partie d’une tâche",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "Numéro de la tâche",
                        "schema": {
                            "type": "integer",
                            "example": 2
                        }
                    }
                ],
                "security": [
                    {
                        "Jeton": []
                    }
                ],
                "description": "Seuls les champs envoyés sont changés, ex. {\"fait\": true}.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/Modification"
                            },
                            "example": {
                                "fait": true
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Modifiée",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Tache"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "tags": [
                    "Tâches"
                ],
                "summary": "Supprimer une tâche",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "Numéro de la tâche",
                        "schema": {
                            "type": "integer",
                            "example": 2
                        }
                    }
                ],
                "security": [
                    {
                        "Jeton": []
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Supprimée"
                    },
                    "401": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/reinitialiser": {
            "post": {
                "tags": [
                    "Outils"
                ],
                "summary": "Remettre la liste d’origine",
                "security": [
                    {
                        "Jeton": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "La liste d’origine",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/Tache"
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Erreur",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erreur"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "Jeton": {
                "type": "http",
                "scheme": "bearer",
                "description": "Jeton de démonstration : demo-koakdesign"
            }
        },
        "schemas": {
            "Tache": {
                "type": "object",
                "required": [
                    "id",
                    "titre",
                    "fait",
                    "priorite"
                ],
                "properties": {
                    "id": {
                        "type": "integer",
                        "example": 4
                    },
                    "titre": {
                        "type": "string",
                        "example": "Tester l’explorateur"
                    },
                    "fait": {
                        "type": "boolean"
                    },
                    "priorite": {
                        "$ref": "#/components/schemas/Priorite"
                    },
                    "echeance": {
                        "type": "string",
                        "format": "date",
                        "nullable": true
                    }
                }
            },
            "NouvelleTache": {
                "type": "object",
                "required": [
                    "titre"
                ],
                "properties": {
                    "titre": {
                        "type": "string",
                        "example": "Tester l’explorateur"
                    },
                    "fait": {
                        "type": "boolean",
                        "default": false
                    },
                    "priorite": {
                        "$ref": "#/components/schemas/Priorite"
                    },
                    "echeance": {
                        "type": "string",
                        "format": "date",
                        "example": "2026-12-31"
                    }
                }
            },
            "Modification": {
                "type": "object",
                "properties": {
                    "titre": {
                        "type": "string"
                    },
                    "fait": {
                        "type": "boolean"
                    },
                    "priorite": {
                        "$ref": "#/components/schemas/Priorite"
                    },
                    "echeance": {
                        "type": "string",
                        "format": "date"
                    }
                }
            },
            "Priorite": {
                "type": "string",
                "enum": [
                    "normale",
                    "basse",
                    "haute"
                ]
            },
            "Erreur": {
                "type": "object",
                "properties": {
                    "erreur": {
                        "type": "string"
                    }
                }
            }
        }
    }
}