{
  "openapi": "3.1.2",
  "info": {
    "title": "Fake Survey Generator API",
    "description": "This is an API. That generates surveys. Fake ones. For fun. That is all.",
    "contact": {
      "name": "Marcel Michau",
      "url": "https://marcelmichau.dev",
      "email": ""
    },
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    },
    "version": "6.0.238.2022"
  },
  "servers": [
    {
      "url": "https://fakesurveygenerator.mysecondarydomain.com"
    }
  ],
  "paths": {
    "/api/admin/version": {
      "get": {
        "tags": [
          "AdminEndpoints"
        ],
        "summary": "Returns API version information",
        "operationId": "GetVersionInformation",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/api/admin/ping": {
      "get": {
        "tags": [
          "AdminEndpoints"
        ],
        "summary": "Returns a 200 OK Result. Used for testing network latency and as a sanity check",
        "operationId": "Ping",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/api/admin/secret-test": {
      "get": {
        "tags": [
          "AdminEndpoints"
        ],
        "summary": "Retrieves a test secret from Dapr Secret Store. Uses local file in Development & Azure Key Vault in Production",
        "operationId": "SecretTest",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/api/survey/{id}": {
      "get": {
        "tags": [
          "SurveyEndpoints"
        ],
        "summary": "Retrieves a specific Survey",
        "operationId": "GetSurvey",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Primary key of the Survey",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SurveyModel"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "delete": {
        "tags": [
          "SurveyEndpoints"
        ],
        "summary": "Deletes a Survey owned by the current user",
        "operationId": "DeleteSurvey",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Primary key of the Survey",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/api/survey/user": {
      "get": {
        "tags": [
          "SurveyEndpoints"
        ],
        "summary": "Retrieves all Surveys created by the current user",
        "operationId": "GetUserSurveys",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UserSurveyModel"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/api/survey": {
      "post": {
        "tags": [
          "SurveyEndpoints"
        ],
        "summary": "Creates a new Survey",
        "operationId": "CreateSurvey",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSurveyCommand"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SurveyModel"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/api/survey/analyze": {
      "post": {
        "tags": [
          "SurveyEndpoints"
        ],
        "summary": "Analyzes a Survey before creation",
        "operationId": "AnalyzeSurvey",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyzeSurveyCommand"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SurveyAnalysisModel"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/api/user/{id}": {
      "get": {
        "tags": [
          "UserEndpoints"
        ],
        "summary": "Retrieves a specific User",
        "operationId": "GetUser",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Primary key of the User",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserModel"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/api/user/isRegistered": {
      "get": {
        "tags": [
          "UserEndpoints"
        ],
        "summary": "Checks whether or not a User with a specific UserId is already registered in the system",
        "operationId": "IsRegistered",
        "parameters": [
          {
            "name": "userId",
            "in": "query",
            "description": "The external user identifier",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/api/user/register": {
      "post": {
        "tags": [
          "UserEndpoints"
        ],
        "summary": "Registers a new User, using the information from the access token",
        "operationId": "Register",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserModel"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserModel"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "OAuth2": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "AnalyzeSurveyCommand": {
        "required": [
          "surveyTopic",
          "respondentType",
          "surveyOptions"
        ],
        "type": "object",
        "properties": {
          "surveyTopic": {
            "type": "string"
          },
          "respondentType": {
            "type": "string"
          },
          "surveyOptions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyOptionDto"
            }
          }
        }
      },
      "CreateSurveyCommand": {
        "required": [
          "surveyTopic",
          "numberOfRespondents",
          "respondentType",
          "surveyOptions"
        ],
        "type": "object",
        "properties": {
          "surveyTopic": {
            "type": "string"
          },
          "numberOfRespondents": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "respondentType": {
            "type": "string"
          },
          "surveyOptions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyOptionDto"
            }
          }
        }
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "null",
              "string"
            ]
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "SurveyAnalysisModel": {
        "required": [
          "responseShape",
          "responseShapeConfidence",
          "leadingProbability",
          "multipleChoiceProbability",
          "coverageProbability",
          "warnings"
        ],
        "type": "object",
        "properties": {
          "responseShape": {
            "type": "string"
          },
          "responseShapeConfidence": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "leadingProbability": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "multipleChoiceProbability": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "coverageProbability": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyAnalysisWarningModel"
            }
          }
        }
      },
      "SurveyAnalysisWarningModel": {
        "required": [
          "code",
          "title",
          "message",
          "probability"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "probability": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          }
        }
      },
      "SurveyModel": {
        "required": [
          "id",
          "ownerId",
          "ownerExternalUserId",
          "topic",
          "respondentType",
          "numberOfRespondents",
          "isRigged",
          "options",
          "createdBy",
          "createdOn",
          "modifiedBy",
          "modifiedOn"
        ],
        "type": "object",
        "properties": {
          "id": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "ownerId": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "ownerExternalUserId": {
            "type": "string"
          },
          "topic": {
            "type": "string"
          },
          "respondentType": {
            "type": "string"
          },
          "numberOfRespondents": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "isRigged": {
            "type": "boolean"
          },
          "options": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyOptionModel"
            }
          },
          "createdBy": {
            "type": [
              "null",
              "string"
            ]
          },
          "createdOn": {
            "type": "string",
            "format": "date-time"
          },
          "modifiedBy": {
            "type": [
              "null",
              "string"
            ]
          },
          "modifiedOn": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          }
        }
      },
      "SurveyOptionDto": {
        "required": [
          "optionText"
        ],
        "type": "object",
        "properties": {
          "optionText": {
            "type": "string"
          },
          "preferredNumberOfVotes": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "SurveyOptionModel": {
        "required": [
          "optionText",
          "numberOfVotes",
          "preferredNumberOfVotes"
        ],
        "type": "object",
        "properties": {
          "optionText": {
            "type": "string"
          },
          "numberOfVotes": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "preferredNumberOfVotes": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "UserModel": {
        "required": [
          "id",
          "displayName",
          "emailAddress",
          "externalUserId",
          "createdBy",
          "createdOn",
          "modifiedBy",
          "modifiedOn"
        ],
        "type": "object",
        "properties": {
          "id": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "displayName": {
            "type": "string"
          },
          "emailAddress": {
            "type": "string"
          },
          "externalUserId": {
            "type": "string"
          },
          "createdBy": {
            "type": [
              "null",
              "string"
            ]
          },
          "createdOn": {
            "type": "string",
            "format": "date-time"
          },
          "modifiedBy": {
            "type": [
              "null",
              "string"
            ]
          },
          "modifiedOn": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          }
        }
      },
      "UserSurveyModel": {
        "required": [
          "id",
          "topic",
          "respondentType",
          "numberOfRespondents",
          "numberOfOptions",
          "winningOption",
          "winningOptionNumberOfVotes"
        ],
        "type": "object",
        "properties": {
          "id": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "topic": {
            "type": "string"
          },
          "respondentType": {
            "type": "string"
          },
          "numberOfRespondents": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "numberOfOptions": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "winningOption": {
            "type": "string"
          },
          "winningOptionNumberOfVotes": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      }
    },
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "description": "OpenID Connect Authentication",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://marcelmichau.eu.auth0.com/authorize?audience=fake-survey-generator-api",
            "tokenUrl": "https://marcelmichau.eu.auth0.com/oauth/token",
            "scopes": {
              "openid": "Standard OpenID Scope",
              "profile": "Standard OpenID Scope",
              "email": "Standard OpenID Scope"
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "OAuth2": [ ]
    }
  ],
  "tags": [
    {
      "name": "AdminEndpoints"
    },
    {
      "name": "SurveyEndpoints"
    },
    {
      "name": "UserEndpoints"
    }
  ]
}