{
  "openapi": "3.0.4",
  "info": {
    "title": "Phototool API",
    "version": "v1"
  },
  "paths": {
    "/api/requests": {
      "post": {
        "tags": [
          "Request"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRequestDto"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRequestDto"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRequestDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/CreateRequestResultDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateRequestResultDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateRequestResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/requests/{id}": {
      "get": {
        "tags": [
          "Request"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/RequestFormDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestFormDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestFormDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "410": {
            "description": "Gone",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/requests/{id}/upload": {
      "post": {
        "tags": [
          "Request"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/UploadResultDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadResultDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "410": {
            "description": "Gone",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateRequestDto": {
        "required": [
          "providerType",
          "requestType"
        ],
        "type": "object",
        "properties": {
          "providerType": {
            "$ref": "#/components/schemas/ProviderType"
          },
          "requestType": {
            "$ref": "#/components/schemas/RequestType"
          },
          "contractNumber": {
            "maxLength": 100,
            "type": "string",
            "nullable": true
          },
          "licensePlate": {
            "maxLength": 20,
            "type": "string",
            "nullable": true
          },
          "claimNumber": {
            "maxLength": 100,
            "type": "string",
            "nullable": true
          },
          "recipientEmail": {
            "maxLength": 254,
            "type": "string",
            "format": "email",
            "nullable": true
          },
          "phoneNumber": {
            "maxLength": 30,
            "type": "string",
            "format": "tel",
            "nullable": true
          },
          "vin": {
            "maxLength": 17,
            "type": "string",
            "nullable": true
          },
          "validUntilUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "requestedItems": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RequestedItemDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CreateRequestResultDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "uploadUrl": {
            "type": "string",
            "nullable": true
          },
          "validUntil": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "FormItemDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "label": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "$ref": "#/components/schemas/ItemCategory"
          },
          "required": {
            "type": "boolean"
          },
          "maxFiles": {
            "type": "integer",
            "format": "int32"
          },
          "order": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "ItemCategory": {
        "enum": [
          "Document",
          "Photo"
        ],
        "type": "string"
      },
      "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": { }
      },
      "ProviderType": {
        "enum": [
          "Alpa",
          "Lisa",
          "Quoter"
        ],
        "type": "string"
      },
      "RequestFormDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "requestType": {
            "$ref": "#/components/schemas/RequestType"
          },
          "providerType": {
            "$ref": "#/components/schemas/ProviderType"
          },
          "state": {
            "$ref": "#/components/schemas/RequestState"
          },
          "validUntil": {
            "type": "string",
            "format": "date-time"
          },
          "allowedFileTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "maxFileSizeMb": {
            "type": "integer",
            "format": "int32"
          },
          "formDefinition": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormItemDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "RequestState": {
        "enum": [
          "Pending",
          "Done",
          "Expired",
          "Error"
        ],
        "type": "string"
      },
      "RequestType": {
        "enum": [
          "Client",
          "Service",
          "Inspection"
        ],
        "type": "string"
      },
      "RequestedItemDto": {
        "required": [
          "code"
        ],
        "type": "object",
        "properties": {
          "code": {
            "maxLength": 50,
            "minLength": 1,
            "type": "string"
          },
          "isRequired": {
            "type": "boolean"
          },
          "maxFiles": {
            "maximum": 20,
            "minimum": 1,
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UploadResultDto": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UploadedFileResultDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UploadedFileResultDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "itemCode": {
            "type": "string",
            "nullable": true
          },
          "originalFileName": {
            "type": "string",
            "nullable": true
          },
          "sizeBytes": {
            "type": "integer",
            "format": "int64"
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "Enter Bearer token",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ]
    }
  ]
}