{
  "openapi": "3.0.1",
  "info": {
    "title": "Webhooks Credentials",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.mercadoe.com"
    }
  ],
  "paths": {
    "/v1/credentials": {
      "post": {
        "tags": [
          "Credentials"
        ],
        "summary": "Create a credential",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCredentialCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateCredentialResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Credentials"
        ],
        "summary": "Get all credentials",
        "parameters": [
          {
            "name": "pageNumber",
            "in": "query",
            "description": "the page number must be an integer greater than or equal to 1",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "the page size must be an integer greater than or equal to 1",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAllResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/credentials/{id}": {
      "put": {
        "tags": [
          "Credentials"
        ],
        "summary": "Update a credential based on the id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "the credential id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCredentialCommand"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateCredentialResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Credentials"
        ],
        "summary": "Get a credential based on the Id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "the credential id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetByIdResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Credentials"
        ],
        "summary": "Delete a credential based on the Id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "the credential id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteCredentialResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BasicAuthCommand": {
        "type": "object",
        "properties": {
          "username": {
            "type": "string"
          },
          "password": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "BasicAuthResponse": {
        "type": "object",
        "properties": {
          "username": {
            "type": "string"
          },
          "password": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "CreateCredentialCommand": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/CredentialType"
          },
          "basicAuth": {
            "$ref": "#/components/schemas/BasicAuthCommand"
          },
          "oAuth2": {
            "$ref": "#/components/schemas/OAuth2Command"
          }
        },
        "additionalProperties": false
      },
      "CreateCredentialResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "CredentialType": {
        "enum": [
          "BasicAuth",
          "OAuth2"
        ],
        "type": "string"
      },
      "DeleteCredentialResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "GetAllResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GetAllResponseData"
            }
          },
          "hits": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "next": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetAllResponseData": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/CredentialType"
          },
          "name": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetByIdResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/CredentialType"
          },
          "basicAuth": {
            "$ref": "#/components/schemas/BasicAuthResponse"
          },
          "oAuth2": {
            "$ref": "#/components/schemas/OAuth2Response"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "OAuth2Command": {
        "type": "object",
        "properties": {
          "clientId": {
            "type": "string"
          },
          "clientSecret": {
            "type": "string"
          },
          "tokenUrl": {
            "type": "string"
          },
          "scope": {
            "type": "string",
            "nullable": true
          },
          "grantType": {
            "type": "string",
            "nullable": true
          },
          "tokenRequestType": {
            "$ref": "#/components/schemas/TokenRequestType"
          },
          "oAuthOverrides": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "OAuth2Response": {
        "type": "object",
        "properties": {
          "tokenUrl": {
            "type": "string"
          },
          "clientId": {
            "type": "string"
          },
          "clientSecret": {
            "type": "string"
          },
          "scope": {
            "type": "string",
            "nullable": true
          },
          "grantType": {
            "type": "string",
            "nullable": true
          },
          "tokenRequestType": {
            "$ref": "#/components/schemas/TokenRequestType"
          },
          "oAuthOverrides": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": {}
      },
      "TokenRequestType": {
        "enum": [
          "Header",
          "Json",
          "Form"
        ],
        "type": "string"
      },
      "UpdateCredentialCommand": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/CredentialType"
          },
          "basicAuth": {
            "$ref": "#/components/schemas/BasicAuthCommand"
          },
          "oAuth2": {
            "$ref": "#/components/schemas/OAuth2Command"
          }
        },
        "additionalProperties": false
      },
      "UpdateCredentialResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "apiKey",
        "description": "Please enter the word 'Bearer' followed by a space and then your JWT.",
        "name": "Authorization",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "Bearer": []
    }
  ]
}