{
  "openapi": "3.1.1",
  "info": {
    "title": "Dofus Roadmap Authentication API",
    "description": "Authentication and session/token management endpoints.",
    "contact": {
      "name": "Ismail Bennani",
      "url": "https://github.com/ismailbennani/dofus-roadmap/issues",
      "email": "contact@ismailbennani.fr"
    },
    "license": {
      "name": "MIT License",
      "url": "https://opensource.org/license/mit/"
    },
    "version": "0.2.2-alpha.1"
  },
  "servers": [
    {
      "url": "{base}",
      "variables": {
        "base": {
          "default": "https://pr-17.preview.dofus-roadmap.ismailbennani.fr/auth/"
        }
      }
    }
  ],
  "paths": {
    "/register": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Register user",
        "description": "Create a local user account.",
        "operationId": "Register",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RegisterResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/login": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Login",
        "description": "Validate credentials and return an access/refresh token pair.",
        "operationId": "Login",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenPairResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/refresh": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Refresh token",
        "description": "Rotate refresh token and issue a new access token.",
        "operationId": "RefreshToken",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenPairResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/external/{provider}": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "External login",
        "description": "Start OAuth flow with Google or Microsoft.",
        "operationId": "ExternalLogin",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "OAuth provider: google or microsoft",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "returnUrl",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Found"
          },
          "400": {
            "description": "Bad Request"
          }
        }
      }
    },
    "/external/callback": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "External login callback",
        "description": "Finalize external login and return access/refresh token pair.",
        "operationId": "ExternalLoginCallback",
        "parameters": [
          {
            "name": "provider",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenPairResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "400": {
            "description": "Bad Request"
          }
        }
      }
    },
    "/tokens": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "List personal API tokens",
        "description": "List personal API tokens for the authenticated user.",
        "operationId": "ListPersonalApiTokens",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PersonalApiTokenSummaryResponse"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Create personal API token",
        "description": "Create a new personal API token. Raw token is returned once.",
        "operationId": "CreatePersonalApiToken",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePersonalApiTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonalApiTokenCreatedResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/tokens/{tokenId}": {
      "delete": {
        "tags": [
          "Authentication"
        ],
        "summary": "Delete personal API token",
        "description": "Delete one personal API token for the authenticated user.",
        "operationId": "DeletePersonalApiToken",
        "parameters": [
          {
            "name": "tokenId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreatePersonalApiTokenRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string"
          },
          "expires-at": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          }
        }
      },
      "HttpValidationProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "null",
              "string"
            ]
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "LoginRequest": {
        "required": [
          "email",
          "password"
        ],
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "password": {
            "type": "string"
          }
        }
      },
      "PersonalApiTokenCreatedResponse": {
        "required": [
          "token-id",
          "name",
          "token",
          "created-at"
        ],
        "type": "object",
        "properties": {
          "token-id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "token": {
            "type": "string"
          },
          "created-at": {
            "type": "string",
            "format": "date-time"
          },
          "expires-at": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          }
        }
      },
      "PersonalApiTokenSummaryResponse": {
        "required": [
          "token-id",
          "name",
          "created-at"
        ],
        "type": "object",
        "properties": {
          "token-id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "created-at": {
            "type": "string",
            "format": "date-time"
          },
          "expires-at": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "last-used-at": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          }
        }
      },
      "RefreshTokenRequest": {
        "required": [
          "refresh-token"
        ],
        "type": "object",
        "properties": {
          "refresh-token": {
            "type": "string"
          }
        }
      },
      "RegisterRequest": {
        "required": [
          "email",
          "password",
          "display-name"
        ],
        "type": "object",
        "properties": {
          "email": {
            "maxLength": 256,
            "type": "string"
          },
          "password": {
            "maxLength": 128,
            "minLength": 8,
            "type": "string"
          },
          "display-name": {
            "maxLength": 100,
            "type": "string"
          }
        }
      },
      "RegisterResponse": {
        "required": [
          "user-id",
          "email",
          "display-name"
        ],
        "type": "object",
        "properties": {
          "user-id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string"
          },
          "display-name": {
            "type": "string"
          }
        }
      },
      "TokenPairResponse": {
        "required": [
          "access-token",
          "refresh-token"
        ],
        "type": "object",
        "properties": {
          "access-token": {
            "type": "string"
          },
          "refresh-token": {
            "type": "string"
          },
          "expires-at": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          }
        }
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "JWT Bearer token authentication",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ]
    }
  ],
  "tags": [
    {
      "name": "Authentication",
      "description": "Register users, authenticate, refresh sessions, and manage personal API tokens."
    }
  ]
}