{
    "openapi": "3.0.2",
    "info": {
        "title": "AutoDoc API",
        "description": "API description of AutoDoc",
        "version": "1.0"
    },
    "servers": [
        {
            "url": "https://autodoc.home.spale.com/v1",
            "description": "Gloor AutoDoc Server"
        }
    ],
    "tags": [
        {
            "name": "Create",
            "description": "Create new documents/pages"
        },
        {
            "name": "Images",
            "description": "Get documents/pages images/thumbnails"
        },
        {
            "name": "Objects",
            "description": "Retrieve a document/page meta data"
        },
        {
            "name": "Properties",
            "description": "Manipulate properties"
        }
    ],
    "components": {
        "schemas": {
            "page": {
                "description": "page object",
                "type": "object",
                "properties": {
                    "id": {
                        "readOnly": true,
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 18446744073709551615
                    },
                    "documentId": {
                        "readOnly": true,
                        "description": "Link to Document",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 18446744073709551615
                    },
                    "name": {
                        "readOnly": false,
                        "description": "Document name, may be empty",
                        "type": "string"
                    },
                    "created": {
                        "readOnly": true,
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 18446744073709551615
                    },
                    "owner": {
                        "readOnly": true,
                        "description": "Username of document owner",
                        "type": "string"
                    },
                    "status": {
                        "readOnly": true,
                        "description": "Status of document",
                        "type": "string",
                        "enum": [
                            "nodata",
                            "inprogress",
                            "deleted",
                            "ok"
                        ]
                    },
                    "languages": {
                        "readOnly": true,
                        "description": "Languages in document in order of importance",
                        "type": "array",
                        "items": {
                            "type": "string",
                            "enum": [
                                "en",
                                "de",
                                "it",
                                "fr"
                            ]
                        }
                    }
                }
            },
            "document": {
                "description": "Document object",
                "type": "object",
                "properties": {
                    "id": {
                        "readOnly": true,
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 18446744073709551615
                    },
                    "pageId": {
                        "readOnly": true,
                        "description": "Link to PageIds",
                        "type": "array",
                        "items": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 18446744073709551615
                        }
                    },
                    "primaryPage": {
                        "readOnly": true,
                        "description": "Which page is the default page",
                        "type": "string"
                    },
                    "name": {
                        "readOnly": false,
                        "description": "Document name, may be empty",
                        "type": "string"
                    },
                    "created": {
                        "readOnly": true,
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 18446744073709551615
                    },
                    "owner": {
                        "readOnly": true,
                        "description": "Username of document owner",
                        "type": "string"
                    },
                    "status": {
                        "readOnly": true,
                        "description": "Status of document",
                        "type": "string",
                        "enum": [
                            "nodata",
                            "inprogress",
                            "deleted",
                            "ok"
                        ]
                    },
                    "languages": {
                        "readOnly": true,
                        "description": "Languages in document in order of importance",
                        "type": "array",
                        "items": {
                            "type": "string",
                            "enum": [
                                "en",
                                "de",
                                "it",
                                "fr"
                            ]
                        }
                    },
                    "tags": {
                        "readOnly": true,
                        "description": "List of all tags",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "parameters": {},
        "securitySchemes": {
            "basicAuth": {
                "type": "http",
                "scheme": "basic"
            }
        }
    },
    "security": [
        {
            "basicAuth": []
        }
    ],
    "paths": {
        "/documents": {
            "post": {
                "summary": "Create a new document",
                "tags": [
                    "Create"
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/document"
                                }
                            }
                        }
                    }
                }
            },
            "get": {
                "summary": "Returns a list of documents",
                "tags": [
                    "Objects"
                ],
                "parameters": [
                    {
                        "in": "query",
                        "name": "pageSize",
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 1000,
                            "default": 50
                        }
                    },
                    {
                        "in": "query",
                        "name": "pageIndex",
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 65535,
                            "default": 0
                        }
                    },
                    {
                        "in": "query",
                        "name": "filterLanguage",
                        "schema": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "enum": [
                                    "fr",
                                    "de",
                                    "it",
                                    "en"
                                ]
                            }
                        }
                    },
                    {
                        "in": "query",
                        "name": "filterKeyword",
                        "schema": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    },
                    {
                        "in": "query",
                        "name": "filterTag",
                        "schema": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/document"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/documents/{documentId}": {
            "patch": {
                "summary": "Manipulate document properties",
                "tags": [
                    "Properties"
                ],
                "parameters": [
                    {
                        "in": "path",
                        "name": "documentId",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 18446744073709551615
                        }
                    },
                    {
                        "in": "query",
                        "name": "addTags",
                        "required": false,
                        "schema": {
                            "type": "array",
                            "maxItems": 64,
                            "items": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64
                            }
                        }
                    },
                    {
                        "in": "query",
                        "name": "deleteTags",
                        "required": false,
                        "schema": {
                            "type": "array",
                            "maxItems": 64,
                            "items": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64
                            }
                        }
                    },
                    {
                        "in": "query",
                        "name": "name",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            },
            "get": {
                "summary": "retrieve a document meta data",
                "tags": [
                    "Objects"
                ],
                "parameters": [
                    {
                        "in": "path",
                        "name": "documentId",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 18446744073709551615
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/document"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Document not found"
                    }
                }
            }
        },
        "/documents/{documentId}/image": {
            "get": {
                "summary": "Get an image or thumbnail of the document",
                "tags": [
                    "Images"
                ],
                "parameters": [
                    {
                        "in": "path",
                        "name": "documentId",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 18446744073709551615
                        }
                    },
                    {
                        "in": "query",
                        "name": "maxWidth",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 10000
                        }
                    },
                    {
                        "in": "query",
                        "name": "maxHeight",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 10000
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "image/*": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/documents/{documentId}/data": {
            "post": {
                "summary": "Add one (or multiple if PDF) page to the document",
                "tags": [
                    "Create"
                ],
                "parameters": [
                    {
                        "in": "path",
                        "name": "documentId",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 18446744073709551615
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "image/png": {
                            "schema": {
                                "type": "string",
                                "format": "binary"
                            }
                        },
                        "image/jpeg": {
                            "schema": {
                                "type": "string",
                                "format": "binary"
                            }
                        },
                        "application/pdf": {
                            "schema": {
                                "type": "string",
                                "format": "binary"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/pages/{pageId}": {
            "get": {
                "summary": "Get page properties",
                "tags": [
                    "Objects"
                ],
                "parameters": [
                    {
                        "in": "path",
                        "name": "pageId",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 18446744073709551615
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/page"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/pages/{pageId}/image": {
            "get": {
                "summary": "get an image or thumbnail of the page",
                "tags": [
                    "Images"
                ],
                "parameters": [
                    {
                        "in": "path",
                        "name": "pageId",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 18446744073709551615
                        }
                    },
                    {
                        "in": "query",
                        "name": "maxWidth",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 10000
                        }
                    },
                    {
                        "in": "query",
                        "name": "maxHeight",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 10000
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "image/*": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}