{
  "openapi": "3.1.0",
  "info": {
    "title": "ApiMocker Free API",
    "version": "1.0.0",
    "description": "A shared mock REST API for frontend development. Writes are temporary and data resets daily at midnight UTC."
  },
  "servers": [
    {
      "url": "https://api.apimocker.com",
      "description": "Public free API"
    }
  ],
  "tags": [
    {
      "name": "System"
    },
    {
      "name": "User"
    },
    {
      "name": "Post"
    },
    {
      "name": "Todo"
    },
    {
      "name": "Comment"
    },
    {
      "name": "Error simulation"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "tags": [
          "System"
        ],
        "summary": "Check API health",
        "responses": {
          "200": {
            "description": "API is healthy.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "examples": [
                        "OK"
                      ]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "uptime": {
                      "type": "number",
                      "description": "Process uptime in seconds."
                    }
                  },
                  "required": [
                    "status",
                    "timestamp",
                    "uptime"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/users": {
      "get": {
        "operationId": "listUsers",
        "tags": [
          "User"
        ],
        "summary": "List users",
        "description": "Returns users with pagination, sorting, delay, and field filters.",
        "parameters": [
          {
            "name": "_page",
            "in": "query",
            "description": "Page number. The page alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "_limit",
            "in": "query",
            "description": "Items per page. The limit alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          },
          {
            "name": "_sort",
            "in": "query",
            "description": "Resource field used for sorting.",
            "schema": {
              "type": "string",
              "default": "id"
            }
          },
          {
            "name": "_order",
            "in": "query",
            "description": "Sort direction.",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "name_like",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "username",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated users.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/PaginatedResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/User"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createUser",
        "tags": [
          "User"
        ],
        "summary": "Create a user",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created User.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/users/search": {
      "get": {
        "operationId": "searchUsers",
        "tags": [
          "User"
        ],
        "summary": "Search users",
        "description": "Searches user name, username, and email. Returns up to 10 results.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Case-insensitive search text.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    }
                  },
                  "required": [
                    "query",
                    "total",
                    "results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Missing search query.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/users/{id}": {
      "get": {
        "operationId": "getUser",
        "tags": [
          "User"
        ],
        "summary": "Get one user",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User resource.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "404": {
            "description": "User not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "replaceUser",
        "tags": [
          "User"
        ],
        "summary": "Replace a user",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated User.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "404": {
            "description": "User not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateUser",
        "tags": [
          "User"
        ],
        "summary": "Update selected user fields",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated User.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "404": {
            "description": "User not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteUser",
        "tags": [
          "User"
        ],
        "summary": "Delete a user",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted successfully. No response body."
          },
          "404": {
            "description": "User not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/posts": {
      "get": {
        "operationId": "listPosts",
        "tags": [
          "Post"
        ],
        "summary": "List posts",
        "description": "Returns posts with their user summary, pagination, sorting, delay, and filters.",
        "parameters": [
          {
            "name": "_page",
            "in": "query",
            "description": "Page number. The page alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "_limit",
            "in": "query",
            "description": "Items per page. The limit alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          },
          {
            "name": "_sort",
            "in": "query",
            "description": "Resource field used for sorting.",
            "schema": {
              "type": "string",
              "default": "id"
            }
          },
          {
            "name": "_order",
            "in": "query",
            "description": "Sort direction.",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "userId",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "title_like",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "body_like",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated posts.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/PaginatedResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Post"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createPost",
        "tags": [
          "Post"
        ],
        "summary": "Create a post",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PostInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created Post.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Post"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/posts/search": {
      "get": {
        "operationId": "searchPosts",
        "tags": [
          "Post"
        ],
        "summary": "Search posts",
        "description": "Searches post title and body with pagination and sorting.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Case-insensitive search text.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "_page",
            "in": "query",
            "description": "Page number. The page alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "_limit",
            "in": "query",
            "description": "Items per page. The limit alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          },
          {
            "name": "_sort",
            "in": "query",
            "description": "Resource field used for sorting.",
            "schema": {
              "type": "string",
              "default": "id"
            }
          },
          {
            "name": "_order",
            "in": "query",
            "description": "Sort direction.",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Post"
                      }
                    }
                  },
                  "required": [
                    "query",
                    "total",
                    "results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Missing search query.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/posts/{id}": {
      "get": {
        "operationId": "getPost",
        "tags": [
          "Post"
        ],
        "summary": "Get one post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Post resource.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Post"
                }
              }
            }
          },
          "404": {
            "description": "Post not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "replacePost",
        "tags": [
          "Post"
        ],
        "summary": "Replace a post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PostInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated Post.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Post"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "404": {
            "description": "Post not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updatePost",
        "tags": [
          "Post"
        ],
        "summary": "Update selected post fields",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PostPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated Post.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Post"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "404": {
            "description": "Post not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deletePost",
        "tags": [
          "Post"
        ],
        "summary": "Delete a post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted successfully. No response body."
          },
          "404": {
            "description": "Post not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/todos": {
      "get": {
        "operationId": "listTodos",
        "tags": [
          "Todo"
        ],
        "summary": "List todos",
        "description": "Returns todos with their user summary, pagination, sorting, delay, and filters.",
        "parameters": [
          {
            "name": "_page",
            "in": "query",
            "description": "Page number. The page alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "_limit",
            "in": "query",
            "description": "Items per page. The limit alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          },
          {
            "name": "_sort",
            "in": "query",
            "description": "Resource field used for sorting.",
            "schema": {
              "type": "string",
              "default": "id"
            }
          },
          {
            "name": "_order",
            "in": "query",
            "description": "Sort direction.",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "userId",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "completed",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "title_like",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated todos.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/PaginatedResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Todo"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTodo",
        "tags": [
          "Todo"
        ],
        "summary": "Create a todo",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TodoInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created Todo.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Todo"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/todos/search": {
      "get": {
        "operationId": "searchTodos",
        "tags": [
          "Todo"
        ],
        "summary": "Search todos",
        "description": "Searches todo title and description. Returns up to 10 results.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Case-insensitive search text.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Todo"
                      }
                    }
                  },
                  "required": [
                    "query",
                    "total",
                    "results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Missing search query.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/todos/{id}": {
      "get": {
        "operationId": "getTodo",
        "tags": [
          "Todo"
        ],
        "summary": "Get one todo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Todo resource.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Todo"
                }
              }
            }
          },
          "404": {
            "description": "Todo not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "replaceTodo",
        "tags": [
          "Todo"
        ],
        "summary": "Replace a todo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TodoInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated Todo.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Todo"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "404": {
            "description": "Todo not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateTodo",
        "tags": [
          "Todo"
        ],
        "summary": "Update selected todo fields",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TodoPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated Todo.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Todo"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "404": {
            "description": "Todo not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteTodo",
        "tags": [
          "Todo"
        ],
        "summary": "Delete a todo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted successfully. No response body."
          },
          "404": {
            "description": "Todo not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/comments": {
      "get": {
        "operationId": "listComments",
        "tags": [
          "Comment"
        ],
        "summary": "List comments",
        "description": "Returns comments with their post summary, pagination, sorting, delay, and filters.",
        "parameters": [
          {
            "name": "_page",
            "in": "query",
            "description": "Page number. The page alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "_limit",
            "in": "query",
            "description": "Items per page. The limit alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          },
          {
            "name": "_sort",
            "in": "query",
            "description": "Resource field used for sorting.",
            "schema": {
              "type": "string",
              "default": "id"
            }
          },
          {
            "name": "_order",
            "in": "query",
            "description": "Sort direction.",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "body_like",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated comments.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/PaginatedResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Comment"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createComment",
        "tags": [
          "Comment"
        ],
        "summary": "Create a comment",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommentInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created Comment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Comment"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/comments/search": {
      "get": {
        "operationId": "searchComments",
        "tags": [
          "Comment"
        ],
        "summary": "Search comments",
        "description": "Searches comment name, email, and body. Returns up to 10 results.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Case-insensitive search text.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Comment"
                      }
                    }
                  },
                  "required": [
                    "query",
                    "total",
                    "results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Missing search query.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/comments/{id}": {
      "get": {
        "operationId": "getComment",
        "tags": [
          "Comment"
        ],
        "summary": "Get one comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "_delay",
            "in": "query",
            "description": "Artificial response delay in milliseconds.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Comment resource.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Comment"
                }
              }
            }
          },
          "404": {
            "description": "Comment not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "replaceComment",
        "tags": [
          "Comment"
        ],
        "summary": "Replace a comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommentInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated Comment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Comment"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "404": {
            "description": "Comment not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateComment",
        "tags": [
          "Comment"
        ],
        "summary": "Update selected comment fields",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommentPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated Comment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Comment"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "404": {
            "description": "Comment not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteComment",
        "tags": [
          "Comment"
        ],
        "summary": "Delete a comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted successfully. No response body."
          },
          "404": {
            "description": "Comment not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/users/{id}/posts": {
      "get": {
        "operationId": "listUserPosts",
        "tags": [
          "User",
          "Post"
        ],
        "summary": "List a user's posts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "_page",
            "in": "query",
            "description": "Page number. The page alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "_limit",
            "in": "query",
            "description": "Items per page. The limit alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated posts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedPostResponse"
                }
              }
            }
          },
          "404": {
            "description": "User not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/users/{id}/todos": {
      "get": {
        "operationId": "listUserTodos",
        "tags": [
          "User",
          "Todo"
        ],
        "summary": "List a user's todos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "_page",
            "in": "query",
            "description": "Page number. The page alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "_limit",
            "in": "query",
            "description": "Items per page. The limit alias is also supported.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated todos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedTodoResponse"
                }
              }
            }
          },
          "404": {
            "description": "User not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/posts/{id}/likes": {
      "get": {
        "operationId": "getPostLikes",
        "tags": [
          "Post"
        ],
        "summary": "Get a post's like count",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current like count.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "postId": {
                      "type": "integer"
                    },
                    "likes": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "postId",
                    "likes"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Post not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "addPostLike",
        "tags": [
          "Post"
        ],
        "summary": "Add a like to a post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Numeric resource ID.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "integer",
                    "minimum": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Like added.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LikeResult"
                }
              }
            }
          },
          "404": {
            "description": "Post not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/error/404": {
      "get": {
        "operationId": "simulateNotFound",
        "tags": [
          "Error simulation"
        ],
        "summary": "Simulate a 404 response",
        "responses": {
          "404": {
            "description": "Intentional not-found response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/error/500": {
      "get": {
        "operationId": "simulateServerError",
        "tags": [
          "Error simulation"
        ],
        "summary": "Simulate a 500 response",
        "responses": {
          "500": {
            "description": "Intentional server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/error/validation": {
      "get": {
        "operationId": "simulateValidationError",
        "tags": [
          "Error simulation"
        ],
        "summary": "Simulate a validation failure",
        "responses": {
          "400": {
            "description": "Intentional validation error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/error/timeout": {
      "get": {
        "operationId": "simulateTimeout",
        "tags": [
          "Error simulation"
        ],
        "summary": "Simulate a request that never completes",
        "responses": {
          "default": {
            "description": "The server intentionally does not send a response."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "UserSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "name": {
            "type": "string"
          },
          "username": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          }
        },
        "required": [
          "id",
          "name",
          "username",
          "email"
        ]
      },
      "UserInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "username": {
            "type": "string",
            "minLength": 3,
            "maxLength": 50,
            "pattern": "^[A-Za-z0-9_]+$"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "website": {
            "type": "string",
            "format": "uri"
          },
          "address": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "company": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          }
        },
        "required": [
          "name",
          "username",
          "email"
        ],
        "additionalProperties": false
      },
      "UserPatch": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "username": {
            "type": "string",
            "minLength": 3,
            "maxLength": 50,
            "pattern": "^[A-Za-z0-9_]+$"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "website": {
            "type": "string",
            "format": "uri"
          },
          "address": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "company": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          }
        },
        "additionalProperties": false
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "username": {
            "type": "string",
            "minLength": 3,
            "maxLength": 50,
            "pattern": "^[A-Za-z0-9_]+$"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "website": {
            "type": "string",
            "format": "uri"
          },
          "address": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "company": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "id",
          "name",
          "username",
          "email",
          "createdAt",
          "updatedAt"
        ]
      },
      "PostInput": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 5000
          },
          "userId": {
            "type": "integer",
            "minimum": 1,
            "default": 1
          }
        },
        "required": [
          "title",
          "body"
        ],
        "additionalProperties": false
      },
      "PostPatch": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 5000
          },
          "userId": {
            "type": "integer",
            "minimum": 1,
            "default": 1
          }
        },
        "additionalProperties": false
      },
      "Post": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 5000
          },
          "userId": {
            "type": "integer",
            "minimum": 1,
            "default": 1
          },
          "user": {
            "$ref": "#/components/schemas/UserSummary",
            "readOnly": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "id",
          "title",
          "body",
          "userId",
          "user",
          "createdAt",
          "updatedAt"
        ]
      },
      "TodoInput": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "completed": {
            "type": "boolean",
            "default": false
          },
          "userId": {
            "type": "integer",
            "minimum": 1,
            "default": 1
          }
        },
        "required": [
          "title"
        ],
        "additionalProperties": false
      },
      "TodoPatch": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "completed": {
            "type": "boolean",
            "default": false
          },
          "userId": {
            "type": "integer",
            "minimum": 1,
            "default": 1
          }
        },
        "additionalProperties": false
      },
      "Todo": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "completed": {
            "type": "boolean",
            "default": false
          },
          "userId": {
            "type": "integer",
            "minimum": 1,
            "default": 1
          },
          "user": {
            "$ref": "#/components/schemas/UserSummary",
            "readOnly": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "id",
          "title",
          "completed",
          "userId",
          "user",
          "createdAt",
          "updatedAt"
        ]
      },
      "CommentInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "postId": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "name",
          "email",
          "body",
          "postId"
        ],
        "additionalProperties": false
      },
      "CommentPatch": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "postId": {
            "type": "integer",
            "minimum": 1
          }
        },
        "additionalProperties": false
      },
      "Comment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "postId": {
            "type": "integer",
            "minimum": 1
          },
          "post": {
            "type": "object",
            "readOnly": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "title": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "title"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "id",
          "name",
          "email",
          "body",
          "postId",
          "post",
          "createdAt",
          "updatedAt"
        ]
      },
      "Pagination": {
        "type": "object",
        "properties": {
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "totalPages": {
            "type": "integer"
          },
          "hasNext": {
            "type": "boolean"
          },
          "hasPrev": {
            "type": "boolean"
          }
        },
        "required": [
          "page",
          "limit",
          "total",
          "totalPages",
          "hasNext",
          "hasPrev"
        ]
      },
      "PaginatedResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {}
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        },
        "required": [
          "data",
          "pagination"
        ]
      },
      "PaginatedPostResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PaginatedResponse"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Post"
                }
              }
            }
          }
        ]
      },
      "PaginatedTodoResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PaginatedResponse"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Todo"
                }
              }
            }
          }
        ]
      },
      "LikeResult": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "like": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "postId": {
                "type": "integer"
              },
              "userId": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "totalLikes": {
            "type": "integer"
          }
        },
        "required": [
          "message",
          "like",
          "totalLikes"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ValidationError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "examples": [
              "Validation Error"
            ]
          },
          "message": {
            "type": "string",
            "examples": [
              "Invalid input data"
            ]
          },
          "details": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "required": [
          "error",
          "message"
        ]
      }
    }
  }
}