Skip to content

Commit

Permalink
Fixed file edit api call, fixed api generation, updated api documenta…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Forceu committed Feb 3, 2025
1 parent 862ca18 commit b98ceb3
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 182 deletions.
2 changes: 1 addition & 1 deletion build/go-generate/updateApiRouting.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
)

const fileRouting = "../../internal/webserver/api/routings.go"
const fileRouting = "../../internal/webserver/api/routing.go"
const fileOutput = "../../internal/webserver/api/routingParsing.go"

// Function to find all declared types referenced in the RequestParser field
Expand Down
2 changes: 1 addition & 1 deletion internal/webserver/api/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (p *paramFilesModify) ProcessParameter(_ *http.Request) error {
if p.foundHeaders["allowedDownloads"] && p.AllowedDownloads == 0 {
p.UnlimitedDownloads = true
}
if p.foundHeaders["expiryDays"] && p.ExpiryTimestamp == 0 {
if p.foundHeaders["expiryTimestamp"] && p.ExpiryTimestamp == 0 {
p.UnlimitedExpiry = true
}
p.IsPasswordSet = p.foundHeaders["password"]
Expand Down
219 changes: 129 additions & 90 deletions internal/webserver/web/static/apidocumentation/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Gokapi",
"description": "[https://github.com/Forceu/Gokapi](https://github.com/Forceu/Gokapi)\n",
"version": "1.0"
"version": "2.0"
},
"servers": [
{
Expand Down Expand Up @@ -172,16 +172,79 @@
"apikey": ["UPLOAD"]
},
],
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "#/components/schemas/chunkingcomplete"
}
}
},
"required": true
"parameters": [
{
"name": "uuid",
"in": "header",
"required": true,
"schema": {
"type": "string"
},
"description": "The unique ID that was used for the uploaded chunks"
},{
"name": "filename",
"in": "header",
"required": true,
"schema": {
"type": "string"
},
"description": "The filename of the uploaded file"
},
{
"name": "filesize",
"in": "header",
"required": true,
"schema": {
"type": "integer"
},
"description": "The total filesize of the uploaded file in bytes"
},
{
"name": "contenttype",
"in": "header",
"required": false,
"schema": {
"type": "string"
},
"description": "The MIME content type. If empty, application/octet-stream will be used."
},
{
"name": "allowedDownloads",
"in": "header",
"required": false,
"schema": {
"type": "integer"
},
"description": "How many downloads are allowed. Default of 1 will be used if empty. Unlimited if 0 is passed."
},
{
"name": "expiryDays",
"in": "header",
"required": false,
"schema": {
"type": "integer"
},
"description": "How many days the file will be stored. Original value will be used if empty. Unlimited if 0 is passed."
},
{
"name": "password",
"in": "header",
"required": false,
"schema": {
"type": "string"
},
"description": "Password for this file to be set. No password will be used if empty value is passed."
},
{
"name": "nonblocking",
"in": "header",
"required": false,
"schema": {
"type": "boolean"
},
"description": "If true, the call is non blocking and does not wait until the upload is fully processed. No info regarding the file or any errors during the processing will be included in the output."
}
],
"responses": {
"200": {
"description": "Operation successful",
Expand Down Expand Up @@ -258,16 +321,62 @@
"apikey": ["VIEW","UPLOAD"]
},
],
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "#/components/schemas/duplicate"
}
}
},
"required": true
"parameters": [
{
"name": "id",
"in": "header",
"required": true,
"schema": {
"type": "string"
},
"description": "ID of file to be duplicated"
},
{
"name": "allowedDownloads",
"in": "header",
"required": false,
"schema": {
"type": "integer"
},
"description": "How many remaining downloads are allowed. Original value will be used if empty. Unlimited if 0 is passed."
},
{
"name": "expiryDays",
"in": "header",
"required": false,
"schema": {
"type": "integer"
},
"description": "How many days the file will be stored. Original value will be used if empty. Unlimited if 0 is passed."
},
{
"name": "password",
"in": "header",
"required": false,
"schema": {
"type": "string"
},
"description": "Password for this file to be set. No password will be used if empty value is passed."
},
{
"name": "originalPassword",
"in": "header",
"required": false,
"schema": {
"type": "boolean"
},
"description": "Set to true to use the original password. Field \"password\" will be ignored if set."
},
{
"name": "filename",
"in": "header",
"required": false,
"schema": {
"type": "string"
},
"description": "Sets a new filename. Filename will be unchanged if empty."
}
],
"responses": {
"200": {
"description": "Operation successful",
Expand Down Expand Up @@ -1190,38 +1299,7 @@
"description": "Password for this file to be set. No password will be used if empty"
}
}
},"duplicate": {
"required": [
"id"
],
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "ID of file to be duplicated"
},
"allowedDownloads": {
"type": "integer",
"description": "How many downloads are allowed. Original value from web interface will be used if empty. Unlimited if 0 is passed."
},
"expiryDays": {
"type": "integer",
"description": "How many days the file will be stored. Original value from web interface will be used if empty. Unlimited if 0 is passed."
},
"password": {
"type": "string",
"description": "Password for this file to be set. No password will be used if empty."
},
"originalPassword": {
"type": "boolean",
"description": "Set to true to use original password. Field \"password\" will be ignored if not set."
},
"filename": {
"type": "string",
"description": "Sets a new filename. Filename will be unchanged if empty."
}
}
},"chunking": {
},"chunking": {
"required": [
"file","uuid","filesize","offset"
],
Expand All @@ -1245,45 +1323,6 @@
"description": "The chunk's offset starting at the beginning of the file"
}
}
},"chunkingcomplete": {
"required": [
"uuid","filename","filesize"
],
"type": "object",
"properties": {
"uuid": {
"type": "string",
"description": "The unique ID that was used for the uploaded chunks"
},
"filename": {
"type": "string",
"description": "The filename of the uploaded file"
},
"filesize": {
"type": "integer",
"description": "The total filesize of the uploaded file in bytes"
},
"contenttype": {
"type": "string",
"description": "The MIME content type. If empty, application/octet-stream will be used."
},
"allowedDownloads": {
"type": "integer",
"description": "How many downloads are allowed. Default of 1 will be used if empty. Unlimited if 0 is passed."
},
"expiryDays": {
"type": "integer",
"description": "How many days the file will be stored. Default of 14 will be used if empty. Unlimited if 0 is passed."
},
"password": {
"type": "string",
"description": "Password for this file to be set. No password will be used if empty"
},
"nonblocking": {
"type": "boolean",
"description": "If true, the call is non blocking and does not wait until the upload is fully processed. No info regarding the file or any errors during the processing will be included in the output."
}
}
}
},
"securitySchemes": {
Expand Down
Loading

0 comments on commit b98ceb3

Please sign in to comment.