{
  "openapi": "3.0.0",
  "paths": {
    "/links": {
      "post": {
        "operationId": "createLink",
        "description": "Creates a new Short Link.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLinkDTO"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkDTO"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDTO"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDTO"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDTO"
                }
              }
            }
          }
        }
      }
    },
    "/links/{id}": {
      "put": {
        "operationId": "updateLink",
        "description": "Updates an existing Short Link.",
        "parameters": [
          {
            "name": "id",
            "description": "The identifier of the link to update. This is the `id` field of the link object.",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EditLinkDTO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkDTO"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDTO"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDTO"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDTO"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteLink",
        "description": "Deletes an existing Short Link.",
        "parameters": [
          {
            "name": "id",
            "description": "The identifier of the link to delete. This is the `id` field of the link object.",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDTO"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDTO"
                }
              }
            }
          }
        }
      }
    }
  },
  "info": {
    "title": "Short Menu API",
    "description": "",
    "version": "0.0.2",
    "contact": {}
  },
  "tags": [],
  "servers": [
    {
      "url": "https://api.shortmenu.com",
      "description": "Default"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Your Short Menu API Key. Create one at [shm.to/create-api-key](https://shm.to/create-api-key)."
      }
    },
    "schemas": {
      "DomainDTO": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Identifier of the domain."
          },
          "name": {
            "type": "string",
            "description": "Name of the domain, e.g. `shm.to`."
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "ErrorResponseDTO": {
        "type": "object",
        "properties": {
          "code": {
            "enum": [
              "LINK_LIMIT_REACHED"
            ],
            "type": "string"
          },
          "errorDescription": {
            "type": "string"
          }
        },
        "required": [
          "errorDescription"
        ]
      },
      "TagDTO": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "LinkDTO": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Identifier of the short link."
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
             "description": "Reference date and time when the short link was created."
          },
          "destinationUrl": {
            "type": "string",
            "description": "Destination URL of the short link."
          },
          "title": {
            "type": "string",
            "description": "Title of the destination URL (website), if available."
          },
          "slug": {
            "type": "string",
            "description": "Slug of the short link, e.g. `ios`."
          },
          "domain": {
            "$ref": "#/components/schemas/DomainDTO"
          },
          "shortUrl": {
            "type": "string",
            "description": "Full short URL of the short link, e.g. `https://shm.to/ios`."
          },
          "clickCount": {
            "type": "number",
            "description": "Number of times the short link has been clicked."
          },
          "tags": {
            "type": "array",
            "description": "Zero or more tags assigned to the short link.",
            "items": {
              "$ref": "#/components/schemas/TagDTO"
            }
          }
        },
        "required": [
          "id",
          "createdAt",
          "destinationUrl",
          "slug",
          "domain",
          "shortUrl",
          "tags"
        ]
      },
      "CreateLinkDTO": {
        "type": "object",
        "properties": {
          "tags": {
            "type": "array",
            "description": "Zero or more tags to assign to the new short link. If a tag with the same name already exists, it will be reused automatically. Do not pass tag `id` values, unless they already exist in your account.",
            "items": {
              "$ref": "#/components/schemas/TagDTO"
            }
          },
          "destinationUrl": {
            "type": "string",
            "description": "Destination URL of the new short link. Must be a valid URL starting with a scheme such as `https`."
          },
          "domain": {
            "type": "string",
            "description": "Name of the short link domain, e.g. `shm.to`. If your account is set up with custom domains, you can pass their names instead."
          },
          "slug": {
            "type": "string",
            "description": "Optional slug for the new short link. If empty, a random slug will be generated. Must be unique within the domain."
          }
        },
        "required": [
          "tags",
          "destinationUrl",
          "domain"
        ]
      },
      "EditLinkDTO": {
        "type": "object",
        "properties": {
          "destinationUrl": {
            "type": "string",
            "description": "Updated destination URL of the short link. If not provided, the existing destination URL will be kept."
          },
          "tags": {
            "type": "array",
            "description": "Updated tags to assign to the short link. If not provided, the existing tags will be kept.",
            "items": {
              "$ref": "#/components/schemas/TagDTO"
            }
          }
        }
      }
    }
  }
}