{
  "openapi": "3.0.3",
  "info": {
    "title": "zmdb API Specification",
    "version": "1.0.0",
    "description": "Auto-generated OpenAPI specification from zmdb core schema definitions."
  },
  "paths": {
    "/users": {
      "get": {
        "summary": "List users",
        "operationId": "listUsers",
        "responses": {
          "200": {
            "description": "A paginated list of users",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "age": {
                            "type": [
                              "integer",
                              "null"
                            ],
                            "minimum": 0
                          },
                          "email": {
                            "type": "string"
                          },
                          "id": {
                            "type": "integer"
                          },
                          "role": {
                            "type": "string",
                            "enum": [
                              "admin",
                              "user"
                            ]
                          }
                        },
                        "required": [
                          "email",
                          "id",
                          "role"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "cursor": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "hasMore",
                    "items"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create user",
        "operationId": "createUser",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "age": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "minimum": 0
                  },
                  "email": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin",
                      "user"
                    ]
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created user",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "age": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "minimum": 0
                    },
                    "email": {
                      "type": "string"
                    },
                    "id": {
                      "type": "integer"
                    },
                    "role": {
                      "type": "string",
                      "enum": [
                        "admin",
                        "user"
                      ]
                    }
                  },
                  "required": [
                    "email",
                    "id",
                    "role"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/users/search": {
      "get": {
        "summary": "Search users",
        "operationId": "searchUsers",
        "responses": {
          "200": {
            "description": "User search results with relevance scores",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "age": {
                            "type": [
                              "integer",
                              "null"
                            ],
                            "minimum": 0
                          },
                          "email": {
                            "type": "string"
                          },
                          "id": {
                            "type": "integer"
                          },
                          "role": {
                            "type": "string",
                            "enum": [
                              "admin",
                              "user"
                            ]
                          },
                          "_score": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "email",
                          "id",
                          "role"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "cursor": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "hasMore",
                    "items"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/users/{id}": {
      "get": {
        "summary": "Get user by ID",
        "operationId": "getUserById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "age": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "minimum": 0
                    },
                    "email": {
                      "type": "string"
                    },
                    "id": {
                      "type": "integer"
                    },
                    "role": {
                      "type": "string",
                      "enum": [
                        "admin",
                        "user"
                      ]
                    }
                  },
                  "required": [
                    "email",
                    "id",
                    "role"
                  ]
                }
              }
            }
          }
        }
      },
      "patch": {
        "summary": "Update user",
        "operationId": "updateUser",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "age": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "minimum": 0
                  },
                  "email": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin",
                      "user"
                    ]
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated user",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "age": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "minimum": 0
                    },
                    "email": {
                      "type": "string"
                    },
                    "id": {
                      "type": "integer"
                    },
                    "role": {
                      "type": "string",
                      "enum": [
                        "admin",
                        "user"
                      ]
                    }
                  },
                  "required": [
                    "email",
                    "id",
                    "role"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/orders": {
      "get": {
        "summary": "List orders",
        "operationId": "listOrders",
        "responses": {
          "200": {
            "description": "A paginated list of orders",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "total": {
                            "type": "number",
                            "minimum": 0
                          },
                          "userId": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "id",
                          "total",
                          "userId"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "cursor": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "hasMore",
                    "items"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create order",
        "operationId": "createOrder",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "total": {
                    "type": "number",
                    "minimum": 0
                  },
                  "userId": {
                    "type": "integer"
                  }
                },
                "required": [
                  "total",
                  "userId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "number",
                      "minimum": 0
                    },
                    "userId": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "id",
                    "total",
                    "userId"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "total": {
            "type": "number",
            "minimum": 0
          },
          "userId": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "total",
          "userId"
        ]
      },
      "Product": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "price": {
            "type": "number",
            "minimum": 0
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive"
            ]
          }
        },
        "required": [
          "code",
          "id",
          "name",
          "price",
          "status"
        ]
      },
      "Profile": {
        "type": "object",
        "properties": {
          "avatar": {
            "type": "string"
          },
          "bio": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          }
        },
        "required": [
          "avatar",
          "id"
        ]
      },
      "User": {
        "type": "object",
        "properties": {
          "age": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "email": {
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "role": {
            "type": "string",
            "enum": [
              "admin",
              "user"
            ]
          }
        },
        "required": [
          "email",
          "id",
          "role"
        ]
      }
    }
  }
}