{
  "openapi": "3.0.3",
  "info": {
    "title": "Atalaya Obras · API de proveedores",
    "version": "1.0.0",
    "description": "API de demostración para pruebas de WAF."
  },
  "servers": [
    {
      "url": "https://demo.gdiazcheckpoint.net"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Licitacion": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "titulo",
          "obra",
          "tipo",
          "importe",
          "cierre",
          "estado"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^LIC-\\d{4}-\\d{3}$"
          },
          "titulo": {
            "type": "string"
          },
          "obra": {
            "type": "string"
          },
          "tipo": {
            "type": "string",
            "enum": [
              "Suministro",
              "Maquinaria",
              "Servicios"
            ]
          },
          "importe": {
            "type": "integer"
          },
          "cierre": {
            "type": "string",
            "format": "date"
          },
          "estado": {
            "type": "string",
            "enum": [
              "abierta",
              "cerrada"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/auth/login": {
      "post": {
        "summary": "Obtener token",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "usuario",
                  "password"
                ],
                "properties": {
                  "usuario": {
                    "type": "string",
                    "maxLength": 32,
                    "pattern": "^[a-zA-Z0-9_.-]+$"
                  },
                  "password": {
                    "type": "string",
                    "maxLength": 64
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "token_type": {
                      "type": "string"
                    },
                    "expires_in": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Credenciales no válidas",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/licitaciones": {
      "get": {
        "summary": "Buscar licitaciones",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "tipo",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "Suministro",
                "Maquinaria",
                "Servicios"
              ]
            }
          },
          {
            "name": "estado",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "abierta",
                "cerrada"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Licitacion"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/licitaciones/{id}": {
      "get": {
        "summary": "Detalle de licitación",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^LIC-\\d{4}-\\d{3}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Licitacion"
                }
              }
            }
          },
          "404": {
            "description": "No existe"
          }
        }
      }
    },
    "/api/v1/ofertas": {
      "post": {
        "summary": "Presentar oferta",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "licitacion",
                  "importe"
                ],
                "properties": {
                  "licitacion": {
                    "type": "string",
                    "pattern": "^LIC-\\d{4}-\\d{3}$"
                  },
                  "importe": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100000000
                  },
                  "comentario": {
                    "type": "string",
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registrada"
          },
          "400": {
            "description": "Petición incorrecta"
          },
          "401": {
            "description": "Sin token"
          }
        }
      }
    },
    "/api/v1/proveedor": {
      "get": {
        "summary": "Datos del proveedor autenticado",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Sin token"
          }
        }
      }
    }
  }
}