{
  "x-generator": "NSwag v13.10.9.0 (NJsonSchema v10.4.1.0 (Newtonsoft.Json v12.0.0.0))",
  "openapi": "3.0.0",
  "info": {
    "title": "Hacker News Clone API",
    "version": "1.0.0"
  },
  "paths": {
    "/api/accounts/me": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "Accounts_Me",
        "responses": {
          "200": {
            "description": ""
          }
        }
      }
    },
    "/api/accounts": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "operationId": "Accounts_Register",
        "requestBody": {
          "x-name": "cmd",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterViewModel"
              }
            }
          },
          "required": true,
          "x-position": 1
        },
        "responses": {
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "204": {
            "description": ""
          }
        }
      }
    },
    "/api/accounts/token": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "operationId": "Accounts_Login",
        "requestBody": {
          "x-name": "cmd",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginViewModel"
              }
            }
          },
          "required": true,
          "x-position": 1
        },
        "responses": {
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/Comments/{id}": {
      "get": {
        "tags": [
          "Comments"
        ],
        "summary": "Affiche un commentaire.",
        "operationId": "Comments_Show",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "guid"
            },
            "x-position": 1
          }
        ],
        "responses": {
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommentDTO"
                }
              }
            }
          }
        }
      }
    },
    "/api/Comments": {
      "post": {
        "tags": [
          "Comments"
        ],
        "summary": "Publie un nouveau commentaire sur la plateforme.",
        "operationId": "Comments_Create",
        "requestBody": {
          "x-name": "cmd",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishCommentCommand"
              }
            }
          },
          "required": true,
          "x-position": 1
        },
        "responses": {
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "201": {
            "description": ""
          }
        }
      }
    },
    "/api/links": {
      "get": {
        "tags": [
          "Links"
        ],
        "summary": "Récupère la liste liste des derniers liens publiés.",
        "operationId": "Links_GetLatest",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LinkDTO"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Links"
        ],
        "summary": "Permet de publier un nouveau lien sur la plateforme.",
        "operationId": "Links_Create",
        "requestBody": {
          "x-name": "cmd",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishLinkCommand"
              }
            }
          },
          "required": true,
          "x-position": 1
        },
        "responses": {
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "201": {
            "description": ""
          }
        }
      }
    },
    "/api/links/{id}": {
      "get": {
        "tags": [
          "Links"
        ],
        "summary": "Récupère les détails d'un lien.",
        "operationId": "Links_GetById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "guid"
            },
            "x-position": 1
          }
        ],
        "responses": {
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkDTO"
                }
              }
            }
          }
        }
      }
    },
    "/api/links/{id}/comments": {
      "get": {
        "tags": [
          "Links"
        ],
        "summary": "Récupère tous les commentaires associés à un lien.",
        "operationId": "Links_Comments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "guid"
            },
            "x-position": 1
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CommentDTO"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProblemDetails": {
        "type": "object",
        "additionalProperties": {
          "nullable": true
        },
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          },
          "extensions": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {}
          }
        }
      },
      "RegisterViewModel": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "username",
          "password",
          "confirmPassword"
        ],
        "properties": {
          "username": {
            "type": "string",
            "minLength": 1
          },
          "password": {
            "type": "string",
            "minLength": 1
          },
          "confirmPassword": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "LoginViewModel": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "username",
          "password"
        ],
        "properties": {
          "username": {
            "type": "string",
            "minLength": 1
          },
          "password": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "CommentDTO": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "format": "guid"
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "upvotesCount": {
            "type": "integer",
            "format": "int32"
          },
          "downvotesCount": {
            "type": "integer",
            "format": "int32"
          },
          "createdByUsername": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PublishCommentCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "linkId",
          "content"
        ],
        "properties": {
          "linkId": {
            "type": "string",
            "format": "guid",
            "minLength": 1
          },
          "content": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "LinkDTO": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "format": "guid"
          },
          "url": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "upvotesCount": {
            "type": "integer",
            "format": "int32"
          },
          "downvotesCount": {
            "type": "integer",
            "format": "int32"
          },
          "commentsCount": {
            "type": "integer",
            "format": "int32"
          },
          "createdByUsername": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PublishLinkCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "minLength": 1
          }
        }
      }
    },
    "securitySchemes": {
      "JWT": {
        "type": "apiKey",
        "description": "Jeton: Bearer {votre jeton}",
        "name": "Authorization",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "JWT": []
    }
  ]
}