{
  "openapi": "3.0.0",
  "info": {
    "title": "api-scoring",
    "version": "0.0.1",
    "description": "api-scoring",
    "contact": {
      "name": "Haroldo Arias",
      "email": "ihpam25@gmail.com"
    }
  },
  "paths": {
    "/ping": {
      "get": {
        "x-controller-name": "PingController",
        "x-operation-name": "ping",
        "tags": [
          "PingController"
        ],
        "responses": {
          "200": {
            "description": "Ping Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PingResponse"
                }
              }
            }
          }
        },
        "operationId": "PingController.ping"
      }
    },
    "/risk-controller-company/{companyId}": {
      "patch": {
        "x-controller-name": "RiskControllerCompanyController",
        "x-operation-name": "updateByCompanyId",
        "tags": [
          "RiskControllerCompanyController"
        ],
        "responses": {
          "200": {
            "description": "Updated risk controller config",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RiskControllerCompany"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "companyId",
            "in": "path",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "listsDefinitions"
                ],
                "properties": {
                  "listsDefinitions": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "x-parameter-index": 1
        },
        "operationId": "RiskControllerCompanyController.updateByCompanyId"
      },
      "get": {
        "x-controller-name": "RiskControllerCompanyController",
        "x-operation-name": "findByCompanyId",
        "tags": [
          "RiskControllerCompanyController"
        ],
        "responses": {
          "200": {
            "description": "Risk controller config for a company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RiskControllerCompany"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "companyId",
            "in": "path",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "operationId": "RiskControllerCompanyController.findByCompanyId"
      }
    },
    "/risk-controller-company": {
      "post": {
        "x-controller-name": "RiskControllerCompanyController",
        "x-operation-name": "create",
        "tags": [
          "RiskControllerCompanyController"
        ],
        "responses": {
          "200": {
            "description": "Created risk controller config",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RiskControllerCompany"
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "companyId",
                  "listsDefinitions"
                ],
                "properties": {
                  "companyId": {
                    "type": "string"
                  },
                  "listsDefinitions": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "RiskControllerCompanyController.create"
      }
    },
    "/risk-evaluation": {
      "post": {
        "x-controller-name": "RiskEvaluationController",
        "x-operation-name": "evaluateRisk",
        "tags": [
          "RiskEvaluationController"
        ],
        "responses": {
          "200": {
            "description": "Evaluación de riesgo completada exitosamente",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "lists": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "coincidence": {
                              "type": "boolean"
                            },
                            "risk": {
                              "type": "string"
                            },
                            "score": {
                              "type": "number"
                            },
                            "data": {
                              "type": "object",
                              "additionalProperties": true
                            }
                          },
                          "required": [
                            "coincidence",
                            "score",
                            "data"
                          ]
                        }
                      }
                    },
                    "totalScore": {
                      "type": "number"
                    },
                    "risk": {
                      "type": "string",
                      "enum": [
                        "low",
                        "medium",
                        "high"
                      ]
                    }
                  },
                  "required": [
                    "lists",
                    "totalScore",
                    "risk"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Datos de entrada inválidos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "name": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Error interno del servidor",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "name": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "lists",
                  "ficha",
                  "company"
                ],
                "properties": {
                  "lists": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "coincidence": {
                            "type": "boolean"
                          },
                          "risk": {
                            "type": "string"
                          },
                          "data": {
                            "type": "object",
                            "additionalProperties": true
                          }
                        }
                      }
                    }
                  },
                  "ficha": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "company": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "listsDefinitions": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string"
                            },
                            "riskFields": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "fieldName": {
                                    "type": "string"
                                  },
                                  "labelName": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "boolean",
                                      "select",
                                      "number",
                                      "text",
                                      "countries",
                                      "regions",
                                      "cities"
                                    ]
                                  },
                                  "values": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "origin": {
                                    "type": "string",
                                    "enum": [
                                      "lista",
                                      "ficha"
                                    ]
                                  }
                                }
                              }
                            },
                            "customRiskFields": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "fieldName": {
                                    "type": "string"
                                  },
                                  "labelName": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "boolean",
                                      "select",
                                      "number",
                                      "text",
                                      "countries",
                                      "regions",
                                      "cities"
                                    ]
                                  },
                                  "values": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "origin": {
                                    "type": "string",
                                    "enum": [
                                      "lista",
                                      "ficha"
                                    ]
                                  }
                                }
                              }
                            },
                            "rules": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "number"
                                  },
                                  "score": {
                                    "type": "number"
                                  },
                                  "connectors": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "conditions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "number"
                                        },
                                        "field": {
                                          "type": "string"
                                        },
                                        "operator": {
                                          "type": "string",
                                          "enum": [
                                            "equals",
                                            "not_equals",
                                            "gte",
                                            "gt",
                                            "lte",
                                            "lt",
                                            "not_empty",
                                            "is_empty",
                                            "is_not_empty",
                                            "contains",
                                            "not_contains",
                                            "in",
                                            "not_in"
                                          ]
                                        },
                                        "value": {}
                                      }
                                    }
                                  }
                                }
                              }
                            },
                            "customRules": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "number"
                                  },
                                  "score": {
                                    "type": "number"
                                  },
                                  "connectors": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "conditions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "number"
                                        },
                                        "field": {
                                          "type": "string"
                                        },
                                        "operator": {
                                          "type": "string",
                                          "enum": [
                                            "equals",
                                            "not_equals",
                                            "gte",
                                            "gt",
                                            "lte",
                                            "lt",
                                            "not_empty",
                                            "is_empty",
                                            "is_not_empty",
                                            "contains",
                                            "not_contains",
                                            "in",
                                            "not_in"
                                          ]
                                        },
                                        "value": {}
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      },
                      "riskConfiguration": {
                        "type": "object",
                        "properties": {
                          "low": {
                            "type": "object",
                            "properties": {
                              "min": {
                                "type": "number"
                              },
                              "max": {
                                "type": "number"
                              }
                            }
                          },
                          "medium": {
                            "type": "object",
                            "properties": {
                              "min": {
                                "type": "number"
                              },
                              "max": {
                                "type": "number"
                              }
                            }
                          },
                          "high": {
                            "type": "object",
                            "properties": {
                              "min": {
                                "type": "number"
                              },
                              "max": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "RiskEvaluationController.evaluateRisk"
      }
    }
  },
  "servers": [
    {
      "url": "https://scoring-qa.s4febeez.com"
    }
  ],
  "components": {
    "schemas": {
      "RiskControllerCompany": {
        "title": "RiskControllerCompany",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "companyId": {
            "type": "string"
          },
          "listsDefinitions": {
            "type": "array",
            "items": {}
          }
        },
        "required": [
          "companyId"
        ],
        "additionalProperties": true
      },
      "PingResponse": {
        "type": "object",
        "title": "PingResponse",
        "properties": {
          "greeting": {
            "type": "string"
          },
          "date": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "headers": {
            "type": "object",
            "properties": {
              "Content-Type": {
                "type": "string"
              }
            },
            "additionalProperties": true
          }
        }
      }
    }
  }
}