{
  "components": {
    "parameters": {
      "AssetId": {
        "in": "path",
        "name": "asset_id",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "CredentialId": {
        "in": "path",
        "name": "credential_id",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "IdempotencyKey": {
        "in": "header",
        "name": "Idempotency-Key",
        "required": true,
        "schema": {
          "maxLength": 120,
          "minLength": 8,
          "type": "string"
        }
      },
      "IncidentId": {
        "in": "path",
        "name": "incident_id",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "MeterId": {
        "in": "path",
        "name": "meter_id",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "Page": {
        "in": "query",
        "name": "page",
        "schema": {
          "default": 1,
          "minimum": 1,
          "type": "integer"
        }
      },
      "PageSize": {
        "in": "query",
        "name": "page_size",
        "schema": {
          "default": 50,
          "maximum": 200,
          "minimum": 1,
          "type": "integer"
        }
      },
      "WorkOrderId": {
        "in": "path",
        "name": "work_order_id",
        "required": true,
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "content": {
          "application/json": {
            "example": {
              "error": {
                "code": "INVALID_REQUEST",
                "message": "Solicitud inv\u00e1lida"
              }
            },
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Solicitud inv\u00e1lida"
      },
      "Forbidden": {
        "content": {
          "application/json": {
            "example": {
              "error": {
                "code": "FORBIDDEN",
                "message": "Acceso denegado"
              }
            },
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Sin permisos"
      },
      "InternalError": {
        "content": {
          "application/json": {
            "example": {
              "error": {
                "code": "INTERNAL_ERROR",
                "message": "Error interno del servidor"
              }
            },
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Error interno"
      },
      "NotFound": {
        "content": {
          "application/json": {
            "example": {
              "error": {
                "code": "RESOURCE_NOT_FOUND",
                "message": "Recurso no encontrado"
              }
            },
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Recurso no encontrado"
      },
      "RateLimitExceeded": {
        "content": {
          "application/json": {
            "example": {
              "error": {
                "code": "RATE_LIMIT_EXCEEDED",
                "message": "Se ha excedido el l\u00edmite de solicitudes."
              }
            },
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "L\u00edmite de solicitudes excedido",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        }
      },
      "Unauthorized": {
        "content": {
          "application/json": {
            "example": {
              "error": {
                "code": "UNAUTHORIZED",
                "message": "Token inv\u00e1lido o expirado"
              }
            },
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "No autenticado"
      },
      "ValidationError": {
        "content": {
          "application/json": {
            "example": {
              "error": {
                "code": "VALIDATION_ERROR",
                "details": {},
                "message": "Datos inv\u00e1lidos"
              }
            },
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        },
        "description": "Error de validaci\u00f3n"
      }
    },
    "schemas": {
      "Asset": {
        "properties": {
          "asset_code": {
            "type": "string"
          },
          "asset_id": {
            "type": "integer"
          },
          "critical": {
            "type": "boolean"
          },
          "location": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "enum": [
              "operational",
              "maintenance",
              "inactive"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "AssetCreateRequest": {
        "properties": {
          "asset_code": {
            "type": "string"
          },
          "critical": {
            "default": false,
            "type": "boolean"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "asset_code",
          "name"
        ],
        "type": "object"
      },
      "AssetListResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/Asset"
            },
            "type": "array"
          },
          "meta": {
            "properties": {
              "pagination": {
                "$ref": "#/components/schemas/Pagination"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "AssetPatchRequest": {
        "properties": {
          "critical": {
            "type": "boolean"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "enum": [
              "operational",
              "maintenance",
              "inactive"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "AssetResponse": {
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Asset"
          }
        },
        "type": "object"
      },
      "ErrorResponse": {
        "properties": {
          "error": {
            "properties": {
              "code": {
                "example": "RESOURCE_NOT_FOUND",
                "type": "string"
              },
              "details": {
                "additionalProperties": true,
                "type": "object"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "IncidentCreate": {
        "properties": {
          "asset_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "description": {
            "type": "string"
          },
          "equipment_stopped": {
            "default": false,
            "type": "boolean"
          },
          "event_date": {
            "format": "date",
            "type": [
              "string",
              "null"
            ]
          },
          "event_time": {
            "pattern": "^[0-2][0-9]:[0-5][0-9]$",
            "type": [
              "string",
              "null"
            ]
          },
          "location": {
            "maxLength": 200,
            "type": "string"
          },
          "priority": {
            "enum": [
              "baja",
              "media",
              "alta",
              "critica"
            ],
            "type": "string"
          },
          "reported_by": {
            "maxLength": 200,
            "type": "string"
          },
          "reporter_area": {
            "maxLength": 120,
            "type": "string"
          },
          "responsible_area": {
            "maxLength": 120,
            "type": "string"
          },
          "title": {
            "maxLength": 200,
            "type": "string"
          },
          "type": {
            "enum": [
              "mecanica",
              "electrica",
              "hidraulica",
              "seguridad",
              "ambiental",
              "otro"
            ],
            "type": "string"
          }
        },
        "required": [
          "title",
          "description",
          "responsible_area",
          "type"
        ],
        "type": "object"
      },
      "IntegrationCredential": {
        "properties": {
          "active": {
            "type": "boolean"
          },
          "credential_id": {
            "type": "integer"
          },
          "environment": {
            "enum": [
              "test",
              "live"
            ],
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "key_prefix": {
            "type": "string"
          },
          "last_used_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "scopes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "IntegrationCredentialCreate": {
        "properties": {
          "environment": {
            "enum": [
              "test",
              "live"
            ],
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "maxLength": 120,
            "type": "string"
          },
          "scopes": {
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": [
          "name",
          "environment",
          "scopes"
        ],
        "type": "object"
      },
      "LoginRequest": {
        "properties": {
          "empresa_slug": {
            "type": "string"
          },
          "password": {
            "format": "password",
            "type": "string"
          },
          "username": {
            "type": "string"
          }
        },
        "required": [
          "username",
          "password",
          "empresa_slug"
        ],
        "type": "object"
      },
      "LoginResponse": {
        "properties": {
          "empresa_id": {
            "type": "integer"
          },
          "empresa_slug": {
            "type": "string"
          },
          "expires_in": {
            "example": 86400,
            "type": "integer"
          },
          "rol": {
            "type": "string"
          },
          "token": {
            "type": "string"
          },
          "username": {
            "type": "string"
          }
        },
        "required": [
          "token"
        ],
        "type": "object"
      },
      "MeResponse": {
        "properties": {
          "credential_id": {
            "type": "integer"
          },
          "empresa_id": {
            "type": "integer"
          },
          "empresa_slug": {
            "type": "string"
          },
          "identity_type": {
            "enum": [
              "session",
              "jwt",
              "api_key"
            ],
            "type": "string"
          },
          "rol": {
            "type": "string"
          },
          "scopes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "user_id": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "MeterReadingCreate": {
        "properties": {
          "anomaly_type": {
            "enum": [
              "reset",
              "replacement",
              "rollover",
              "sequence_adjustment",
              "out_of_range"
            ],
            "type": "string"
          },
          "correction_of_id": {
            "type": "integer"
          },
          "justification": {
            "maxLength": 500,
            "type": "string"
          },
          "measured_at": {
            "format": "date-time",
            "type": "string"
          },
          "notes": {
            "maxLength": 500,
            "type": "string"
          },
          "value": {
            "type": [
              "number",
              "string"
            ]
          },
          "work_order_id": {
            "type": "integer"
          }
        },
        "required": [
          "value"
        ],
        "type": "object"
      },
      "Pagination": {
        "properties": {
          "page": {
            "type": "integer"
          },
          "page_size": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "Product": {
        "properties": {
          "name": {
            "type": "string"
          },
          "product_id": {
            "type": "integer"
          },
          "sku": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "ResourceCreatedResponse": {
        "properties": {
          "data": {
            "additionalProperties": true,
            "type": "object"
          },
          "meta": {
            "properties": {
              "api_version": {
                "example": "v1",
                "type": "string"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "User": {
        "properties": {
          "name": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "user_id": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "VersionResponse": {
        "properties": {
          "application": {
            "const": "Roustix",
            "type": "string"
          },
          "commit": {
            "description": "SHA Git abreviado; solo aparece cuando la plataforma lo suministra.",
            "example": "ea86634abc12",
            "type": "string"
          },
          "release": {
            "example": "v1.0.0",
            "type": "string"
          },
          "version": {
            "example": "1.0.0",
            "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)",
            "type": "string"
          }
        },
        "required": [
          "application",
          "version",
          "release"
        ],
        "type": "object"
      },
      "WorkOrder": {
        "properties": {
          "asset_id": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "work_order_id": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "WorkOrderListResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/WorkOrder"
            },
            "type": "array"
          },
          "meta": {
            "properties": {
              "pagination": {
                "$ref": "#/components/schemas/Pagination"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "bearerFormat": "JWT or rtx_* API key",
        "description": "JWT de usuario o API key de integraci\u00f3n \u00b7 MAG-02",
        "scheme": "bearer",
        "type": "http"
      },
      "cookieAuth": {
        "description": "Sesi\u00f3n web administrativa de Roustix",
        "in": "cookie",
        "name": "session",
        "type": "apiKey"
      }
    }
  },
  "info": {
    "contact": {
      "name": "Roustix Developer Support",
      "url": "https://developer.roustix.app"
    },
    "description": "Contrato oficial Roustix API v1 \u2014 fuente machine-readable alineada a MAG v1.0.\nMAG describe la API para personas; OpenAPI describe la misma API para herramientas.\n",
    "license": {
      "name": "Proprietary",
      "url": "https://roustix.app/terms"
    },
    "title": "Roustix API",
    "version": "1.0.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/admin/integration-credentials": {
      "get": {
        "operationId": "integrationCredentialsList",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/IntegrationCredential"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Credenciales sin secretos recuperables"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "security": [
          {
            "cookieAuth": []
          }
        ],
        "summary": "Listar credenciales de integraci\u00f3n del tenant",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "El campo secret aparece \u00fanicamente en esta respuesta.",
        "operationId": "integrationCredentialsCreate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationCredentialCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Credencial emitida con secreto de visualizaci\u00f3n \u00fanica"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "security": [
          {
            "cookieAuth": []
          }
        ],
        "summary": "Crear credencial de integraci\u00f3n",
        "tags": [
          "Admin"
        ]
      }
    },
    "/admin/integration-credentials/{credential_id}/revoke": {
      "post": {
        "operationId": "integrationCredentialsRevoke",
        "parameters": [
          {
            "$ref": "#/components/parameters/CredentialId"
          }
        ],
        "responses": {
          "200": {
            "description": "Credencial revocada"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "security": [
          {
            "cookieAuth": []
          }
        ],
        "summary": "Revocar credencial inmediatamente",
        "tags": [
          "Admin"
        ]
      }
    },
    "/admin/integration-credentials/{credential_id}/rotate": {
      "post": {
        "operationId": "integrationCredentialsRotate",
        "parameters": [
          {
            "$ref": "#/components/parameters/CredentialId"
          }
        ],
        "responses": {
          "201": {
            "description": "Nueva credencial y secreto de visualizaci\u00f3n \u00fanica"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "security": [
          {
            "cookieAuth": []
          }
        ],
        "summary": "Rotar credencial",
        "tags": [
          "Admin"
        ]
      }
    },
    "/admin/summary": {
      "get": {
        "operationId": "adminSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "M\u00e9tricas resumidas"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "summary": "Resumen administrativo del tenant",
        "tags": [
          "Admin"
        ]
      }
    },
    "/auth/login": {
      "post": {
        "description": "Emite token JWT con contexto de tenant (empresa_slug).",
        "operationId": "authLogin",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoginResponse"
                }
              }
            },
            "description": "Token emitido"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitExceeded"
          }
        },
        "security": [],
        "summary": "Login JWT",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/inventory/products": {
      "get": {
        "operationId": "inventoryProductsList",
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Product"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Pagination"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Lista paginada de productos"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "summary": "Listar productos",
        "tags": [
          "Inventory"
        ],
        "x-mag-status": "planned"
      }
    },
    "/maintenance/assets": {
      "get": {
        "operationId": "maintenanceAssetsList",
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssetListResponse"
                }
              }
            },
            "description": "Lista paginada de activos"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "summary": "Listar activos",
        "tags": [
          "Maintenance"
        ]
      },
      "post": {
        "operationId": "maintenanceAssetsCreate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssetCreateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceCreatedResponse"
                }
              }
            },
            "description": "Activo creado"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        },
        "summary": "Crear activo",
        "tags": [
          "Maintenance"
        ]
      }
    },
    "/maintenance/assets/{asset_id}": {
      "get": {
        "operationId": "maintenanceAssetsGet",
        "parameters": [
          {
            "$ref": "#/components/parameters/AssetId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssetResponse"
                }
              }
            },
            "description": "Activo"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "summary": "Obtener activo",
        "tags": [
          "Maintenance"
        ]
      },
      "patch": {
        "operationId": "maintenanceAssetsPatch",
        "parameters": [
          {
            "$ref": "#/components/parameters/AssetId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssetPatchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssetResponse"
                }
              }
            },
            "description": "Activo actualizado"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        },
        "summary": "Actualizar activo",
        "tags": [
          "Maintenance"
        ]
      }
    },
    "/maintenance/assets/{asset_id}/meters": {
      "get": {
        "operationId": "maintenanceAssetMetersList",
        "parameters": [
          {
            "$ref": "#/components/parameters/AssetId"
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "in": "query",
            "name": "active",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "updated_since",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Medidores paginados"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "summary": "Listar medidores de un activo",
        "tags": [
          "Maintenance"
        ]
      }
    },
    "/maintenance/incidents": {
      "get": {
        "operationId": "maintenanceIncidentsList",
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "priority",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "asset_id",
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "updated_since",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Incidencias paginadas"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "summary": "Listar incidencias del tenant",
        "tags": [
          "Maintenance"
        ]
      },
      "post": {
        "operationId": "maintenanceIncidentsCreate",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IncidentCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Incidencia creada o respuesta idempotente"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "409": {
            "description": "Conflicto de idempotencia"
          }
        },
        "summary": "Reportar incidencia de forma idempotente",
        "tags": [
          "Maintenance"
        ]
      }
    },
    "/maintenance/incidents/{incident_id}": {
      "get": {
        "operationId": "maintenanceIncidentsGet",
        "parameters": [
          {
            "$ref": "#/components/parameters/IncidentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Incidencia del tenant"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "summary": "Consultar incidencia",
        "tags": [
          "Maintenance"
        ]
      }
    },
    "/maintenance/meters/{meter_id}/readings": {
      "get": {
        "operationId": "maintenanceMeterReadingsList",
        "parameters": [
          {
            "$ref": "#/components/parameters/MeterId"
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "in": "query",
            "name": "measured_since",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "measured_until",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lecturas paginadas"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "summary": "Listar lecturas de un medidor",
        "tags": [
          "Maintenance"
        ]
      },
      "post": {
        "operationId": "maintenanceMeterReadingsCreate",
        "parameters": [
          {
            "$ref": "#/components/parameters/MeterId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MeterReadingCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Lectura creada o respuesta idempotente"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "409": {
            "description": "Conflicto de idempotencia"
          }
        },
        "summary": "Registrar lectura idempotente",
        "tags": [
          "Maintenance"
        ]
      }
    },
    "/maintenance/work-orders": {
      "get": {
        "operationId": "maintenanceWorkOrdersList",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrderListResponse"
                }
              }
            },
            "description": "Lista paginada"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "summary": "Listar \u00f3rdenes de trabajo",
        "tags": [
          "Maintenance"
        ],
        "x-mag-status": "planned"
      }
    },
    "/maintenance/work-orders/{work_order_id}": {
      "get": {
        "operationId": "maintenanceWorkOrdersGet",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkOrderId"
          }
        ],
        "responses": {
          "200": {
            "description": "Orden de trabajo del tenant"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "summary": "Consultar orden de trabajo",
        "tags": [
          "Maintenance"
        ]
      }
    },
    "/me": {
      "get": {
        "operationId": "authMe",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeResponse"
                }
              }
            },
            "description": "Usuario y tenant del JWT"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "summary": "Contexto del tenant activo",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/version": {
      "get": {
        "operationId": "systemVersion",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VersionResponse"
                }
              }
            },
            "description": "Versi\u00f3n SemVer y build desplegado"
          }
        },
        "security": [],
        "summary": "Consultar versi\u00f3n de Roustix",
        "tags": [
          "System"
        ]
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "servers": [
    {
      "description": "Producci\u00f3n",
      "url": "https://api.roustix.app/api/v1"
    },
    {
      "description": "Desarrollo local",
      "url": "http://127.0.0.1:5000/api/v1"
    }
  ],
  "tags": [
    {
      "description": "Metadatos p\u00fablicos y seguros de la aplicaci\u00f3n",
      "name": "System"
    },
    {
      "description": "JWT \u00b7 MAG-02",
      "name": "Authentication"
    },
    {
      "description": "Activos \u00b7 \u00f3rdenes \u00b7 mantenimiento \u00b7 MAG-04",
      "name": "Maintenance"
    },
    {
      "description": "Productos \u00b7 stock \u00b7 almacenes",
      "name": "Inventory"
    },
    {
      "description": "Compras",
      "name": "Purchasing"
    },
    {
      "description": "Ventas",
      "name": "Sales"
    },
    {
      "description": "Clientes y relaciones",
      "name": "CRM"
    },
    {
      "description": "Administraci\u00f3n del tenant",
      "name": "Admin"
    }
  ]
}
