{
  "openapi": "3.0.4",
  "info": {
    "title": "Cloudhub API",
    "version": "v1"
  },
  "paths": {
    "/api/sessions/services": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "identifier",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "identifierType",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/IdentifierTypes"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TrustServiceInfoModel"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TrustServiceInfoModel"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TrustServiceInfoModel"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions/services/{name}/availability": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "identifier",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "identifierType",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/IdentifierTypes"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/GetServiceAvailabilityResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetServiceAvailabilityResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetServiceAvailabilityResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/SessionCreateRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionCreateRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionCreateRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/SessionCreateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/SessionModel"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionModel"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionModel"
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions/services/{name}": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceSessionCreateRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceSessionCreateRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceSessionCreateRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceSessionCreateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceSessionCreateResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceSessionCreateResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceSessionCreateResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions/certificate": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "session",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              },
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              },
              "text/json": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/sessions/certificate": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "session",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/CertificateModel"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CertificateModel"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/CertificateModel"
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions/sign-hash": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/SignHashRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignHashRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/SignHashRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/SignHashRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              },
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              },
              "text/json": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions/custom-state": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "session",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "type": "string"
                }
              },
              "text/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CertificateModel": {
        "type": "object",
        "properties": {
          "content": {
            "type": "string",
            "format": "byte",
            "nullable": true
          },
          "alias": {
            "type": "string",
            "nullable": true
          },
          "serviceName": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GetServiceAvailabilityResponse": {
        "type": "object",
        "properties": {
          "discoveryAvailable": {
            "type": "boolean"
          },
          "certificateFound": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "IdentifierTypes": {
        "enum": [
          "CPF",
          "CNPJ"
        ],
        "type": "string"
      },
      "ServiceSessionCreateRequest": {
        "required": [
          "redirectUri"
        ],
        "type": "object",
        "properties": {
          "identifier": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/TrustServiceSessionTypes"
          },
          "redirectUri": {
            "minLength": 1,
            "type": "string"
          },
          "lifetimeInSeconds": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "customState": {
            "type": "string",
            "nullable": true
          },
          "discover": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ServiceSessionCreateResponse": {
        "type": "object",
        "properties": {
          "serviceInfo": {
            "$ref": "#/components/schemas/TrustServiceInfoModel"
          },
          "authUrl": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SessionCreateRequest": {
        "required": [
          "redirectUri"
        ],
        "type": "object",
        "properties": {
          "identifierType": {
            "$ref": "#/components/schemas/IdentifierTypes"
          },
          "identifier": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/TrustServiceSessionTypes"
          },
          "redirectUri": {
            "minLength": 1,
            "type": "string"
          },
          "lifetimeInSeconds": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "customState": {
            "type": "string",
            "nullable": true
          },
          "discover": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SessionModel": {
        "type": "object",
        "properties": {
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TrustServiceAuthParametersModel"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SignHashRequest": {
        "required": [
          "hash",
          "session"
        ],
        "type": "object",
        "properties": {
          "session": {
            "minLength": 1,
            "type": "string"
          },
          "hash": {
            "type": "string",
            "format": "byte"
          },
          "digestAlgorithm": {
            "type": "string",
            "nullable": true
          },
          "digestAlgorithmOid": {
            "type": "string",
            "nullable": true
          },
          "certificateAlias": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TrustServiceAuthParametersModel": {
        "type": "object",
        "properties": {
          "serviceInfo": {
            "$ref": "#/components/schemas/TrustServiceInfoModel"
          },
          "authUrl": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TrustServiceInfoModel": {
        "type": "object",
        "properties": {
          "serviceName": {
            "type": "string",
            "nullable": true
          },
          "provider": {
            "type": "string",
            "nullable": true
          },
          "endpoint": {
            "type": "string",
            "nullable": true
          },
          "badgeUrl": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TrustServiceSessionTypes": {
        "enum": [
          "SingleSignature",
          "MultiSignature",
          "SignatureSession",
          "AuthenticationSession"
        ],
        "type": "string"
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "description": "Api Key authentication",
        "name": "X-Api-Key",
        "in": "header"
      }
    }
  },
  "tags": [
    {
      "name": "Sessions"
    }
  ]
}