{
  "openapi": "3.0.0",
  "info": {
    "title": "Invicti Vulnerable API with Auth",
    "version": "1.0.0",
    "description": "An sample API demonstrating OWASP Top 10 API Security Risks"
  },
  "servers": [
    {
      "url": "http://vulnapi.testinvicti.com",
      "description": "Production server"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/token": {
      "get": {
        "summary": "Get JWT Token",
        "description": "Returns a JWT token for guest access",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "JWT token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/validateToken": {
      "post": {
        "summary": "Validate JWT Token",
        "description": "Checks if the provided JWT token is valid",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token is valid",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "decoded": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid token or no token provided"
          }
        }
      }
    },
    "/api/users/{id}": {
      "get": {
        "summary": "Get a user by ID",
        "tags": [
          "Users"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer",
              "default": 2
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User details"
          },
          "404": {
            "description": "User not found"
          }
        }
      },
      "put": {
        "summary": "Update a user",
        "tags": [
          "Users"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer",
              "default": 4
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "User updated"
          },
          "404": {
            "description": "User not found"
          },
          "500": {
            "description": "Server error"
          }
        }
      },
      "delete": {
        "summary": "Delete a user",
        "tags": [
          "Users"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User deleted"
          },
          "403": {
            "description": "Cannot delete users with ID 4 or lower"
          },
          "404": {
            "description": "User not found"
          }
        }
      },
      "patch": {
        "summary": "Partially update a user",
        "tags": [
          "Users"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer",
              "default": 4
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "User updated successfully"
          },
          "404": {
            "description": "User not found"
          },
          "500": {
            "description": "Server error"
          }
        }
      }
    },
    "/api/login": {
      "post": {
        "summary": "Login to get a token",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Login successful"
          },
          "401": {
            "description": "Invalid credentials"
          }
        }
      }
    },
    "/api/data": {
      "get": {
        "summary": "Get a large amount of data",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Array of data"
          }
        }
      }
    },
    "/api/orders": {
      "post": {
        "summary": "Create a new order",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "product": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Order created"
          }
        }
      },
      "get": {
        "summary": "Get all orders",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of all orders"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/orders/{id}": {
      "delete": {
        "summary": "Delete an order",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order deleted successfully"
          },
          "403": {
            "description": "Unauthorized to delete this order"
          },
          "404": {
            "description": "Order not found"
          }
        }
      },
      "get": {
        "summary": "Get an order by ID",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order details"
          },
          "404": {
            "description": "Order not found"
          }
        }
      }
    },
    "/api/fetch": {
      "get": {
        "summary": "Fetch data from a URL",
        "tags": [
          "Users"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "url",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fetched data"
          },
          "500": {
            "description": "Failed to fetch data"
          }
        }
      }
    },
    "/api/v1/users": {
      "get": {
        "summary": "Get all users (v1)",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "List of all users"
          }
        }
      }
    },
    "/api/v2/users": {
      "get": {
        "summary": "Get all users (v2)",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "List of all users (limited information)"
          }
        }
      }
    },
    "/api/proxy": {
      "get": {
        "summary": "Proxy a request to another URL",
        "tags": [
          "Users"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "url",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Proxied content"
          },
          "400": {
            "description": "Invalid URL"
          },
          "500": {
            "description": "Error occurred"
          }
        }
      }
    },
    "/api/users": {
      "post": {
        "summary": "Create a new user",
        "tags": [
          "Users"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "isAdmin": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "User created successfully"
          },
          "400": {
            "description": "Username already exists or invalid input"
          }
        }
      }
    },
    "/api/admin/users": {
      "get": {
        "summary": "Get all users (admin only)",
        "description": "Retrieve a list of all users. Requires admin privileges, except in dev environment.",
        "tags": [
          "Admin"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "A list of all users"
          },
          "403": {
            "description": "Access denied"
          }
        }
      }
    },
    "/api/admin/users/{id}": {
      "get": {
        "summary": "Get a user by ID (admin only)",
        "description": "Retrieve a user by their ID. Requires admin privileges.",
        "tags": [
          "Admin"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer",
              "default": 4
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User details"
          },
          "403": {
            "description": "Access denied"
          },
          "404": {
            "description": "User not found"
          }
        }
      },
      "put": {
        "summary": "Update a user (admin only)",
        "description": "Update a user's details by their ID. Requires admin privileges.",
        "tags": [
          "Admin"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer",
              "default": 4
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "isAdmin": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "User updated successfully"
          },
          "403": {
            "description": "Access denied"
          },
          "404": {
            "description": "User not found"
          }
        }
      },
      "delete": {
        "summary": "Delete a user (admin only)",
        "description": "Delete a user by their ID. Requires admin privileges.",
        "tags": [
          "Admin"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User deleted successfully"
          },
          "403": {
            "description": "Access denied"
          },
          "404": {
            "description": "User not found"
          }
        }
      }
    },
    "/api/users/{id}/orders": {
      "get": {
        "summary": "Get all orders for a specific user",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of user's orders"
          },
          "404": {
            "description": "User not found"
          }
        }
      }
    },
    "/api/users/{id}/avatar": {
      "post": {
        "summary": "Upload a user avatar",
        "tags": [
          "Users"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "avatar": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Avatar uploaded successfully"
          },
          "404": {
            "description": "User not found"
          }
        }
      }
    },
    "/api/avatars/{fname}": {
      "get": {
        "summary": "Get an avatar by filename",
        "tags": [
          "Users"
        ],
        "security": [],
        "parameters": [
          {
            "in": "path",
            "name": "fname",
            "required": true,
            "schema": {
              "type": "string",
              "default": "ac8b55c2e0341e18ef86a290a9fabefc"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Avatar file"
          },
          "404": {
            "description": "Avatar not found"
          }
        }
      }
    },
    "/api/me": {
      "get": {
        "summary": "Get the current user's information",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Current user's information"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/admin/orders": {
      "get": {
        "summary": "Get all orders (admin only)",
        "tags": [
          "Admin",
          "Orders"
        ],
        "responses": {
          "200": {
            "description": "List of all orders"
          },
          "403": {
            "description": "Access denied"
          }
        }
      }
    },
    "/api/admin/products": {
      "get": {
        "summary": "Get all products (admin only)",
        "tags": [
          "Admin",
          "Products"
        ],
        "responses": {
          "200": {
            "description": "List of all products"
          },
          "403": {
            "description": "Access denied"
          },
          "500": {
            "description": "Server error"
          }
        }
      },
      "post": {
        "summary": "Create a new product (admin only)",
        "tags": [
          "Admin",
          "Products"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "price": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Product created successfully"
          },
          "403": {
            "description": "Access denied"
          },
          "500": {
            "description": "Server error"
          }
        }
      }
    },
    "/api/admin/products/{id}": {
      "get": {
        "summary": "Get a product by ID (admin only)",
        "tags": [
          "Admin",
          "Products"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Product details"
          },
          "403": {
            "description": "Access denied"
          },
          "404": {
            "description": "Product not found"
          },
          "500": {
            "description": "Server error"
          }
        }
      },
      "delete": {
        "summary": "Delete a product (admin only)",
        "tags": [
          "Admin",
          "Products"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Product deleted successfully"
          },
          "403": {
            "description": "Access denied"
          },
          "404": {
            "description": "Product not found"
          },
          "500": {
            "description": "Server error"
          }
        }
      }
    },
    "/api/admin/logs": {
      "get": {
        "summary": "Get application logs (admin only)",
        "tags": [
          "Admin"
        ],
        "responses": {
          "200": {
            "description": "List of application logs"
          },
          "403": {
            "description": "Access denied"
          }
        }
      }
    },
    "/api/search": {
      "get": {
        "summary": "Search across multiple entities (users, orders, products)",
        "tags": [
          "Search"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "q",
            "schema": {
              "type": "string",
              "default": "admin"
            },
            "description": "Search query"
          }
        ],
        "responses": {
          "200": {
            "description": "Search results"
          }
        }
      }
    },
    "/api/users/search": {
      "get": {
        "summary": "Search users",
        "tags": [
          "Search",
          "Users"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "q",
            "schema": {
              "type": "string"
            },
            "description": "Search query"
          }
        ],
        "responses": {
          "200": {
            "description": "Search results"
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "security": [],
        "summary": "Check the health status of the API",
        "tags": [
          "Health"
        ],
        "responses": {
          "200": {
            "description": "API is healthy"
          }
        }
      }
    },
    "/api/metrics": {
      "get": {
        "summary": "Get API usage metrics",
        "tags": [
          "Health"
        ],
        "responses": {
          "200": {
            "description": "API usage metrics"
          }
        }
      }
    },
    "/api/notes/{id}": {
      "get": {
        "summary": "Get a note by ID from a microservice",
        "tags": [
          "Notes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer",
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Note details"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Note not found"
          },
          "500": {
            "description": "Server error"
          }
        }
      }
    },
    "/vulns": {
      "get": {
        "summary": "Get the list of security issues as HTML",
        "tags": [
          "Security"
        ],
        "responses": {
          "200": {
            "description": "HTML content of security issues"
          },
          "500": {
            "description": "Server error"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Authentication",
      "description": "User authentication endpoints"
    },
    {
      "name": "Users",
      "description": "User management endpoints"
    },
    {
      "name": "Orders",
      "description": "Order management endpoints"
    },
    {
      "name": "Products",
      "description": "Product management endpoints"
    },
    {
      "name": "Admin",
      "description": "Admin-only endpoints"
    },
    {
      "name": "Search",
      "description": "Search functionality endpoints"
    },
    {
      "name": "Health",
      "description": "API health and metrics endpoints"
    }
  ]
}