diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b6d860..2298d36 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,7 +56,7 @@ jobs: - name: Generate Swagger Documentation run: | # Generate Swagger documentation - $(go env GOPATH)/bin/swag init + $(go env GOPATH)/bin/swag init --tags \!Internal # Configure Git git config --local user.email "action@github.com" diff --git a/docs/docs.go b/docs/docs.go index c2aab0c..6e8e8a0 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -15,44 +15,9 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/accounts": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get all accounts - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "[ADMIN] Get all accounts", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Account" - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, + "/login": { "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new account - for admin use only", + "description": "Logs in a user by providing username and password", "consumes": [ "application/json" ], @@ -60,36 +25,41 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Accounts" + "Public" ], - "summary": "[ADMIN] Create a new account", + "summary": "User login", "parameters": [ { - "description": "Account Information", - "name": "input", + "description": "Username", + "name": "username", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dataset.Account" + "type": "string" + } + }, + { + "description": "Password", + "name": "password", + "in": "body", + "required": true, + "schema": { + "type": "string" } } ], "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.Account" - } - }, - "400": { - "description": "error", + "200": { + "description": "token", "schema": { "type": "object", - "additionalProperties": true + "additionalProperties": { + "type": "string" + } } }, - "500": { - "description": "error", + "403": { + "description": "error: credentials are incorrect or token generation failed", "schema": { "type": "object", "additionalProperties": true @@ -98,33 +68,24 @@ const docTemplate = `{ } } }, - "/accounts/{id}": { + "/myaccount": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get account by ID - for admin use only", + "description": "Get information of the currently logged-in user", "produces": [ "application/json" ], "tags": [ "Accounts" ], - "summary": "[ADMIN] Get account by ID", - "parameters": [ - { - "type": "integer", - "description": "Account ID", - "name": "id", - "in": "path", - "required": true - } - ], + "summary": "Get account info", "responses": { "200": { - "description": "OK", + "description": "Account Information", "schema": { "$ref": "#/definitions/dataset.Account" } @@ -158,7 +119,7 @@ const docTemplate = `{ "Bearer": [] } ], - "description": "Update account by ID - for admin use only", + "description": "Update information of the currently logged-in user", "consumes": [ "application/json" ], @@ -168,15 +129,8 @@ const docTemplate = `{ "tags": [ "Accounts" ], - "summary": "[ADMIN] Update account by ID", + "summary": "Update account info", "parameters": [ - { - "type": "integer", - "description": "Account ID", - "name": "id", - "in": "path", - "required": true - }, { "description": "Account Information", "name": "input", @@ -209,72 +163,26 @@ const docTemplate = `{ } } } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete account by ID - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "[ADMIN] Delete account by ID", - "parameters": [ - { - "type": "integer", - "description": "Account ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "Account deleted", - "schema": { - "type": "string" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } } }, - "/inventories": { + "/myinventory": { "get": { "security": [ { "Bearer": [] } ], - "description": "Retrieves a list of all inventories - for admin use only", + "description": "Retrieves a list of all inventories of the user", "produces": [ "application/json" ], "tags": [ "Inventories" ], - "summary": "[ADMIN] Get all inventories", + "summary": "Get all inventories of the user", "responses": { "200": { - "description": "List of Inventories", + "description": "OK", "schema": { "type": "array", "items": { @@ -297,7 +205,7 @@ const docTemplate = `{ "Bearer": [] } ], - "description": "Creates an inventory - for admin use only", + "description": "Creates an inventory", "consumes": [ "application/json" ], @@ -307,7 +215,7 @@ const docTemplate = `{ "tags": [ "Inventories" ], - "summary": "[ADMIN] Create an inventory", + "summary": "Create an inventory", "parameters": [ { "description": "Inventory", @@ -343,21 +251,21 @@ const docTemplate = `{ } } }, - "/inventories/{id}": { + "/myinventory/{id}": { "get": { "security": [ { "Bearer": [] } ], - "description": "Retrieves an inventory by ID - for admin use only", + "description": "Retrieves an inventory by ID", "produces": [ "application/json" ], "tags": [ "Inventories" ], - "summary": "[ADMIN] Get an inventory by ID", + "summary": "Get an inventory by ID", "parameters": [ { "type": "integer", @@ -381,952 +289,36 @@ const docTemplate = `{ "additionalProperties": true } }, - "404": { - "description": "Inventory not found", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Updates an inventory by ID - for admin use only", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "[ADMIN] Update an inventory by ID", - "parameters": [ - { - "type": "integer", - "description": "Inventory ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Inventory", - "name": "inventory", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - }, - "400": { - "description": "Invalid payload", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Deletes an inventory by ID - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "[ADMIN] Delete an inventory by ID", - "parameters": [ - { - "type": "integer", - "description": "Inventory ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "Inventory deleted", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Invalid ID format", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/login": { - "post": { - "description": "Logs in a user by providing username and password", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "User login", - "parameters": [ - { - "description": "Username", - "name": "username", - "in": "body", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "Password", - "name": "password", - "in": "body", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "token", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "403": { - "description": "error: credentials are incorrect or token generation failed", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/myaccount": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get information of the currently logged-in user", - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "Get account info", - "responses": { - "200": { - "description": "Account Information", - "schema": { - "$ref": "#/definitions/dataset.Account" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "404": { - "description": "error: Account not found", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update information of the currently logged-in user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "Update account info", - "parameters": [ - { - "description": "Account Information", - "name": "input", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Account" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Account" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/myinventory": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Retrieves a list of all inventories of the user", - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "Get all inventories of the user", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.Inventory" - } - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Creates an inventory", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "Create an inventory", - "parameters": [ - { - "description": "Inventory", - "name": "inventory", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - }, - "400": { - "description": "Invalid payload", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/myinventory/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Retrieves an inventory by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "Get an inventory by ID", - "parameters": [ - { - "type": "integer", - "description": "Inventory ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - }, - "400": { - "description": "Invalid ID format", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "403": { - "description": "This item does not belong to you", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "404": { - "description": "Inventory not found", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Updates an inventory by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "Update an inventory by ID", - "parameters": [ - { - "type": "integer", - "description": "Inventory ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Inventory", - "name": "inventory", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - }, - "400": { - "description": "Invalid payload", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "403": { - "description": "This item does not belong to you", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypack": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new pack", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Create a new pack", - "parameters": [ - { - "description": "Pack", - "name": "pack", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypack/import": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Import from lighterpack csv pack file", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Import from lighterpack csv pack file", - "parameters": [ - { - "type": "file", - "description": "CSV file", - "name": "file", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "message", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypack/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get pack by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Get pack by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "404": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update a pack by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Update a pack by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Pack", - "name": "pack", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete a pack by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Delete a pack by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "message", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypackcontent": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new pack content", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Create a new pack content", - "parameters": [ - { - "description": "Pack Content", - "name": "packcontent", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypackcontent/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get pack content by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Get pack content by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack Content ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } - }, - "400": { - "description": "error", + "403": { + "description": "This item does not belong to you", "schema": { "type": "object", "additionalProperties": true } }, "404": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete a pack content by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Delete a pack content by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack Content ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "message", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypacks": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get all packs - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "[ADMIN] Get all packs", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.Pack" - } + "description": "Inventory not found", + "schema": { + "type": "object", + "additionalProperties": true } }, "500": { - "description": "error", + "description": "Internal Server Error", "schema": { "type": "object", "additionalProperties": true } } } - } - }, - "/mypassword": { + }, "put": { "security": [ { "Bearer": [] } ], - "description": "Update the password of the current logged-in user", + "description": "Updates an inventory by ID", "consumes": [ "application/json" ], @@ -1334,36 +326,50 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Accounts" + "Inventories" ], - "summary": "Update password", + "summary": "Update an inventory by ID", "parameters": [ { - "description": "Updated Password", - "name": "password", + "type": "integer", + "description": "Inventory ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Inventory", + "name": "inventory", "in": "body", "required": true, "schema": { - "type": "string" + "$ref": "#/definitions/dataset.Inventory" } } ], "responses": { "200": { - "description": "Updated password successfully", + "description": "OK", "schema": { - "type": "string" + "$ref": "#/definitions/dataset.Inventory" } }, "400": { - "description": "error", + "description": "Invalid payload", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "403": { + "description": "This item does not belong to you", "schema": { "type": "object", "additionalProperties": true } }, "500": { - "description": "error", + "description": "Internal Server Error", "schema": { "type": "object", "additionalProperties": true @@ -1372,29 +378,47 @@ const docTemplate = `{ } } }, - "/packcontents": { - "get": { + "/mypack": { + "post": { "security": [ { "Bearer": [] } ], - "description": "Get all pack contents - for admin use only", + "description": "Create a new pack", + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Get all pack contents", + "summary": "Create a new pack", + "parameters": [ + { + "description": "Pack", + "name": "pack", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dataset.Pack" + } + } + ], "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.PackContent" - } + "$ref": "#/definitions/dataset.Pack" + } + }, + "400": { + "description": "error", + "schema": { + "type": "object", + "additionalProperties": true } }, "500": { @@ -1405,16 +429,18 @@ const docTemplate = `{ } } } - }, + } + }, + "/mypack/import": { "post": { "security": [ { "Bearer": [] } ], - "description": "Create a new pack content - for admin use only", + "description": "Import from lighterpack csv pack file", "consumes": [ - "application/json" + "multipart/form-data" ], "produces": [ "application/json" @@ -1422,33 +448,27 @@ const docTemplate = `{ "tags": [ "Packs" ], - "summary": "[ADMIN] Create a new pack content", + "summary": "Import from lighterpack csv pack file", "parameters": [ { - "description": "Pack Content", - "name": "packcontent", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } + "type": "file", + "description": "CSV file", + "name": "file", + "in": "formData", + "required": true } ], "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } - }, - "400": { - "description": "error", + "200": { + "description": "message", "schema": { "type": "object", - "additionalProperties": true + "additionalProperties": { + "type": "string" + } } }, - "500": { + "400": { "description": "error", "schema": { "type": "object", @@ -1458,25 +478,25 @@ const docTemplate = `{ } } }, - "/packcontents/{id}": { + "/mypack/{id}": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get pack content by ID - for admin use only", + "description": "Get pack by ID", "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Get pack content by ID", + "summary": "Get pack by ID", "parameters": [ { "type": "integer", - "description": "Pack Content ID", + "description": "Pack ID", "name": "id", "in": "path", "required": true @@ -1486,7 +506,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dataset.PackContent" + "$ref": "#/definitions/dataset.Pack" } }, "400": { @@ -1518,7 +538,7 @@ const docTemplate = `{ "Bearer": [] } ], - "description": "Update a pack content by ID - for admin use only", + "description": "Update a pack by ID", "consumes": [ "application/json" ], @@ -1528,22 +548,22 @@ const docTemplate = `{ "tags": [ "Packs" ], - "summary": "[ADMIN] Update a pack content by ID", + "summary": "Update a pack by ID", "parameters": [ { "type": "integer", - "description": "Pack Content ID", + "description": "Pack ID", "name": "id", "in": "path", "required": true }, { - "description": "Pack Content", - "name": "packcontent", + "description": "Pack", + "name": "pack", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dataset.PackContent" + "$ref": "#/definitions/dataset.Pack" } } ], @@ -1551,7 +571,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dataset.PackContent" + "$ref": "#/definitions/dataset.Pack" } }, "400": { @@ -1576,18 +596,18 @@ const docTemplate = `{ "Bearer": [] } ], - "description": "Delete a pack content by ID - for admin use only", + "description": "Delete a pack by ID", "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Delete a pack content by ID", + "summary": "Delete a pack by ID", "parameters": [ { "type": "integer", - "description": "Pack Content ID", + "description": "Pack ID", "name": "id", "in": "path", "required": true @@ -1620,47 +640,14 @@ const docTemplate = `{ } } }, - "/packs": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get all packs - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "[ADMIN] Get all packs", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.Pack" - } - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, + "/mypackcontent": { "post": { "security": [ { "Bearer": [] } ], - "description": "Create a new pack - for admin use only", + "description": "Create a new pack content", "consumes": [ "application/json" ], @@ -1670,15 +657,15 @@ const docTemplate = `{ "tags": [ "Packs" ], - "summary": "[ADMIN] Create a new pack", + "summary": "Create a new pack content", "parameters": [ { - "description": "Pack", - "name": "pack", + "description": "Pack Content", + "name": "packcontent", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dataset.Pack" + "$ref": "#/definitions/dataset.PackContent" } } ], @@ -1686,7 +673,7 @@ const docTemplate = `{ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/dataset.Pack" + "$ref": "#/definitions/dataset.PackContent" } }, "400": { @@ -1706,29 +693,49 @@ const docTemplate = `{ } } }, - "/packs/:id/packcontents": { + "/mypackcontent/{id}": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get all pack contents - for admin use only", + "description": "Get pack content by ID", "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Get all pack contents", + "summary": "Get pack content by ID", + "parameters": [ + { + "type": "integer", + "description": "Pack Content ID", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.PackContent" - } + "$ref": "#/definitions/dataset.PackContent" + } + }, + "400": { + "description": "error", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "error", + "schema": { + "type": "object", + "additionalProperties": true } }, "500": { @@ -1739,27 +746,25 @@ const docTemplate = `{ } } } - } - }, - "/packs/{id}": { - "get": { + }, + "delete": { "security": [ { "Bearer": [] } ], - "description": "Get pack by ID - for admin use only", + "description": "Delete a pack content by ID", "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Get pack by ID", + "summary": "Delete a pack content by ID", "parameters": [ { "type": "integer", - "description": "Pack ID", + "description": "Pack Content ID", "name": "id", "in": "path", "required": true @@ -1767,19 +772,15 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - }, - "400": { - "description": "error", + "description": "message", "schema": { "type": "object", - "additionalProperties": true + "additionalProperties": { + "type": "string" + } } }, - "404": { + "400": { "description": "error", "schema": { "type": "object", @@ -1794,14 +795,16 @@ const docTemplate = `{ } } } - }, + } + }, + "/mypassword": { "put": { "security": [ { "Bearer": [] } ], - "description": "Update a pack by ID - for admin use only", + "description": "Update the password of the current logged-in user", "consumes": [ "application/json" ], @@ -1809,32 +812,25 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Packs" + "Accounts" ], - "summary": "[ADMIN] Update a pack by ID", + "summary": "Update password", "parameters": [ { - "type": "integer", - "description": "Pack ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Pack", - "name": "pack", + "description": "Updated Password", + "name": "password", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dataset.Pack" + "type": "string" } } ], "responses": { "200": { - "description": "OK", + "description": "Updated password successfully", "schema": { - "$ref": "#/definitions/dataset.Pack" + "type": "string" } }, "400": { @@ -1864,7 +860,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Accounts" + "Public" ], "summary": "Register new user", "parameters": [ diff --git a/docs/swagger.json b/docs/swagger.json index 375603c..22c83f8 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -9,44 +9,9 @@ "host": "pimpmypack.alki.earth", "basePath": "/api/v1", "paths": { - "/accounts": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get all accounts - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "[ADMIN] Get all accounts", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Account" - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, + "/login": { "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new account - for admin use only", + "description": "Logs in a user by providing username and password", "consumes": [ "application/json" ], @@ -54,36 +19,41 @@ "application/json" ], "tags": [ - "Accounts" + "Public" ], - "summary": "[ADMIN] Create a new account", + "summary": "User login", "parameters": [ { - "description": "Account Information", - "name": "input", + "description": "Username", + "name": "username", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dataset.Account" + "type": "string" + } + }, + { + "description": "Password", + "name": "password", + "in": "body", + "required": true, + "schema": { + "type": "string" } } ], "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.Account" - } - }, - "400": { - "description": "error", + "200": { + "description": "token", "schema": { "type": "object", - "additionalProperties": true + "additionalProperties": { + "type": "string" + } } }, - "500": { - "description": "error", + "403": { + "description": "error: credentials are incorrect or token generation failed", "schema": { "type": "object", "additionalProperties": true @@ -92,33 +62,24 @@ } } }, - "/accounts/{id}": { + "/myaccount": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get account by ID - for admin use only", + "description": "Get information of the currently logged-in user", "produces": [ "application/json" ], "tags": [ "Accounts" ], - "summary": "[ADMIN] Get account by ID", - "parameters": [ - { - "type": "integer", - "description": "Account ID", - "name": "id", - "in": "path", - "required": true - } - ], + "summary": "Get account info", "responses": { "200": { - "description": "OK", + "description": "Account Information", "schema": { "$ref": "#/definitions/dataset.Account" } @@ -152,7 +113,7 @@ "Bearer": [] } ], - "description": "Update account by ID - for admin use only", + "description": "Update information of the currently logged-in user", "consumes": [ "application/json" ], @@ -162,15 +123,8 @@ "tags": [ "Accounts" ], - "summary": "[ADMIN] Update account by ID", + "summary": "Update account info", "parameters": [ - { - "type": "integer", - "description": "Account ID", - "name": "id", - "in": "path", - "required": true - }, { "description": "Account Information", "name": "input", @@ -203,72 +157,26 @@ } } } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete account by ID - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "[ADMIN] Delete account by ID", - "parameters": [ - { - "type": "integer", - "description": "Account ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "Account deleted", - "schema": { - "type": "string" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } } }, - "/inventories": { + "/myinventory": { "get": { "security": [ { "Bearer": [] } ], - "description": "Retrieves a list of all inventories - for admin use only", + "description": "Retrieves a list of all inventories of the user", "produces": [ "application/json" ], "tags": [ "Inventories" ], - "summary": "[ADMIN] Get all inventories", + "summary": "Get all inventories of the user", "responses": { "200": { - "description": "List of Inventories", + "description": "OK", "schema": { "type": "array", "items": { @@ -291,7 +199,7 @@ "Bearer": [] } ], - "description": "Creates an inventory - for admin use only", + "description": "Creates an inventory", "consumes": [ "application/json" ], @@ -301,7 +209,7 @@ "tags": [ "Inventories" ], - "summary": "[ADMIN] Create an inventory", + "summary": "Create an inventory", "parameters": [ { "description": "Inventory", @@ -337,21 +245,21 @@ } } }, - "/inventories/{id}": { + "/myinventory/{id}": { "get": { "security": [ { "Bearer": [] } ], - "description": "Retrieves an inventory by ID - for admin use only", + "description": "Retrieves an inventory by ID", "produces": [ "application/json" ], "tags": [ "Inventories" ], - "summary": "[ADMIN] Get an inventory by ID", + "summary": "Get an inventory by ID", "parameters": [ { "type": "integer", @@ -375,952 +283,36 @@ "additionalProperties": true } }, - "404": { - "description": "Inventory not found", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Updates an inventory by ID - for admin use only", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "[ADMIN] Update an inventory by ID", - "parameters": [ - { - "type": "integer", - "description": "Inventory ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Inventory", - "name": "inventory", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - }, - "400": { - "description": "Invalid payload", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Deletes an inventory by ID - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "[ADMIN] Delete an inventory by ID", - "parameters": [ - { - "type": "integer", - "description": "Inventory ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "Inventory deleted", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Invalid ID format", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/login": { - "post": { - "description": "Logs in a user by providing username and password", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "User login", - "parameters": [ - { - "description": "Username", - "name": "username", - "in": "body", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "Password", - "name": "password", - "in": "body", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "token", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "403": { - "description": "error: credentials are incorrect or token generation failed", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/myaccount": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get information of the currently logged-in user", - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "Get account info", - "responses": { - "200": { - "description": "Account Information", - "schema": { - "$ref": "#/definitions/dataset.Account" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "404": { - "description": "error: Account not found", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update information of the currently logged-in user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Accounts" - ], - "summary": "Update account info", - "parameters": [ - { - "description": "Account Information", - "name": "input", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Account" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Account" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/myinventory": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Retrieves a list of all inventories of the user", - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "Get all inventories of the user", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.Inventory" - } - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Creates an inventory", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "Create an inventory", - "parameters": [ - { - "description": "Inventory", - "name": "inventory", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - }, - "400": { - "description": "Invalid payload", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/myinventory/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Retrieves an inventory by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "Get an inventory by ID", - "parameters": [ - { - "type": "integer", - "description": "Inventory ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - }, - "400": { - "description": "Invalid ID format", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "403": { - "description": "This item does not belong to you", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "404": { - "description": "Inventory not found", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Updates an inventory by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Inventories" - ], - "summary": "Update an inventory by ID", - "parameters": [ - { - "type": "integer", - "description": "Inventory ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Inventory", - "name": "inventory", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Inventory" - } - }, - "400": { - "description": "Invalid payload", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "403": { - "description": "This item does not belong to you", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypack": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new pack", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Create a new pack", - "parameters": [ - { - "description": "Pack", - "name": "pack", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypack/import": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Import from lighterpack csv pack file", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Import from lighterpack csv pack file", - "parameters": [ - { - "type": "file", - "description": "CSV file", - "name": "file", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "message", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypack/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get pack by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Get pack by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "404": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update a pack by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Update a pack by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Pack", - "name": "pack", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete a pack by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Delete a pack by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "message", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypackcontent": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new pack content", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Create a new pack content", - "parameters": [ - { - "description": "Pack Content", - "name": "packcontent", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypackcontent/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get pack content by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Get pack content by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack Content ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } - }, - "400": { - "description": "error", + "403": { + "description": "This item does not belong to you", "schema": { "type": "object", "additionalProperties": true } }, "404": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete a pack content by ID", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "Delete a pack content by ID", - "parameters": [ - { - "type": "integer", - "description": "Pack Content ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "message", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "/mypacks": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get all packs - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "[ADMIN] Get all packs", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.Pack" - } + "description": "Inventory not found", + "schema": { + "type": "object", + "additionalProperties": true } }, "500": { - "description": "error", + "description": "Internal Server Error", "schema": { "type": "object", "additionalProperties": true } } } - } - }, - "/mypassword": { + }, "put": { "security": [ { "Bearer": [] } ], - "description": "Update the password of the current logged-in user", + "description": "Updates an inventory by ID", "consumes": [ "application/json" ], @@ -1328,36 +320,50 @@ "application/json" ], "tags": [ - "Accounts" + "Inventories" ], - "summary": "Update password", + "summary": "Update an inventory by ID", "parameters": [ { - "description": "Updated Password", - "name": "password", + "type": "integer", + "description": "Inventory ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Inventory", + "name": "inventory", "in": "body", "required": true, "schema": { - "type": "string" + "$ref": "#/definitions/dataset.Inventory" } } ], "responses": { "200": { - "description": "Updated password successfully", + "description": "OK", "schema": { - "type": "string" + "$ref": "#/definitions/dataset.Inventory" } }, "400": { - "description": "error", + "description": "Invalid payload", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "403": { + "description": "This item does not belong to you", "schema": { "type": "object", "additionalProperties": true } }, "500": { - "description": "error", + "description": "Internal Server Error", "schema": { "type": "object", "additionalProperties": true @@ -1366,29 +372,47 @@ } } }, - "/packcontents": { - "get": { + "/mypack": { + "post": { "security": [ { "Bearer": [] } ], - "description": "Get all pack contents - for admin use only", + "description": "Create a new pack", + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Get all pack contents", + "summary": "Create a new pack", + "parameters": [ + { + "description": "Pack", + "name": "pack", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dataset.Pack" + } + } + ], "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.PackContent" - } + "$ref": "#/definitions/dataset.Pack" + } + }, + "400": { + "description": "error", + "schema": { + "type": "object", + "additionalProperties": true } }, "500": { @@ -1399,16 +423,18 @@ } } } - }, + } + }, + "/mypack/import": { "post": { "security": [ { "Bearer": [] } ], - "description": "Create a new pack content - for admin use only", + "description": "Import from lighterpack csv pack file", "consumes": [ - "application/json" + "multipart/form-data" ], "produces": [ "application/json" @@ -1416,33 +442,27 @@ "tags": [ "Packs" ], - "summary": "[ADMIN] Create a new pack content", + "summary": "Import from lighterpack csv pack file", "parameters": [ { - "description": "Pack Content", - "name": "packcontent", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } + "type": "file", + "description": "CSV file", + "name": "file", + "in": "formData", + "required": true } ], "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/dataset.PackContent" - } - }, - "400": { - "description": "error", + "200": { + "description": "message", "schema": { "type": "object", - "additionalProperties": true + "additionalProperties": { + "type": "string" + } } }, - "500": { + "400": { "description": "error", "schema": { "type": "object", @@ -1452,25 +472,25 @@ } } }, - "/packcontents/{id}": { + "/mypack/{id}": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get pack content by ID - for admin use only", + "description": "Get pack by ID", "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Get pack content by ID", + "summary": "Get pack by ID", "parameters": [ { "type": "integer", - "description": "Pack Content ID", + "description": "Pack ID", "name": "id", "in": "path", "required": true @@ -1480,7 +500,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dataset.PackContent" + "$ref": "#/definitions/dataset.Pack" } }, "400": { @@ -1512,7 +532,7 @@ "Bearer": [] } ], - "description": "Update a pack content by ID - for admin use only", + "description": "Update a pack by ID", "consumes": [ "application/json" ], @@ -1522,22 +542,22 @@ "tags": [ "Packs" ], - "summary": "[ADMIN] Update a pack content by ID", + "summary": "Update a pack by ID", "parameters": [ { "type": "integer", - "description": "Pack Content ID", + "description": "Pack ID", "name": "id", "in": "path", "required": true }, { - "description": "Pack Content", - "name": "packcontent", + "description": "Pack", + "name": "pack", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dataset.PackContent" + "$ref": "#/definitions/dataset.Pack" } } ], @@ -1545,7 +565,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dataset.PackContent" + "$ref": "#/definitions/dataset.Pack" } }, "400": { @@ -1570,18 +590,18 @@ "Bearer": [] } ], - "description": "Delete a pack content by ID - for admin use only", + "description": "Delete a pack by ID", "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Delete a pack content by ID", + "summary": "Delete a pack by ID", "parameters": [ { "type": "integer", - "description": "Pack Content ID", + "description": "Pack ID", "name": "id", "in": "path", "required": true @@ -1614,47 +634,14 @@ } } }, - "/packs": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get all packs - for admin use only", - "produces": [ - "application/json" - ], - "tags": [ - "Packs" - ], - "summary": "[ADMIN] Get all packs", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.Pack" - } - } - }, - "500": { - "description": "error", - "schema": { - "type": "object", - "additionalProperties": true - } - } - } - }, + "/mypackcontent": { "post": { "security": [ { "Bearer": [] } ], - "description": "Create a new pack - for admin use only", + "description": "Create a new pack content", "consumes": [ "application/json" ], @@ -1664,15 +651,15 @@ "tags": [ "Packs" ], - "summary": "[ADMIN] Create a new pack", + "summary": "Create a new pack content", "parameters": [ { - "description": "Pack", - "name": "pack", + "description": "Pack Content", + "name": "packcontent", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dataset.Pack" + "$ref": "#/definitions/dataset.PackContent" } } ], @@ -1680,7 +667,7 @@ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/dataset.Pack" + "$ref": "#/definitions/dataset.PackContent" } }, "400": { @@ -1700,29 +687,49 @@ } } }, - "/packs/:id/packcontents": { + "/mypackcontent/{id}": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get all pack contents - for admin use only", + "description": "Get pack content by ID", "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Get all pack contents", + "summary": "Get pack content by ID", + "parameters": [ + { + "type": "integer", + "description": "Pack Content ID", + "name": "id", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/dataset.PackContent" - } + "$ref": "#/definitions/dataset.PackContent" + } + }, + "400": { + "description": "error", + "schema": { + "type": "object", + "additionalProperties": true + } + }, + "404": { + "description": "error", + "schema": { + "type": "object", + "additionalProperties": true } }, "500": { @@ -1733,27 +740,25 @@ } } } - } - }, - "/packs/{id}": { - "get": { + }, + "delete": { "security": [ { "Bearer": [] } ], - "description": "Get pack by ID - for admin use only", + "description": "Delete a pack content by ID", "produces": [ "application/json" ], "tags": [ "Packs" ], - "summary": "[ADMIN] Get pack by ID", + "summary": "Delete a pack content by ID", "parameters": [ { "type": "integer", - "description": "Pack ID", + "description": "Pack Content ID", "name": "id", "in": "path", "required": true @@ -1761,19 +766,15 @@ ], "responses": { "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dataset.Pack" - } - }, - "400": { - "description": "error", + "description": "message", "schema": { "type": "object", - "additionalProperties": true + "additionalProperties": { + "type": "string" + } } }, - "404": { + "400": { "description": "error", "schema": { "type": "object", @@ -1788,14 +789,16 @@ } } } - }, + } + }, + "/mypassword": { "put": { "security": [ { "Bearer": [] } ], - "description": "Update a pack by ID - for admin use only", + "description": "Update the password of the current logged-in user", "consumes": [ "application/json" ], @@ -1803,32 +806,25 @@ "application/json" ], "tags": [ - "Packs" + "Accounts" ], - "summary": "[ADMIN] Update a pack by ID", + "summary": "Update password", "parameters": [ { - "type": "integer", - "description": "Pack ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Pack", - "name": "pack", + "description": "Updated Password", + "name": "password", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dataset.Pack" + "type": "string" } } ], "responses": { "200": { - "description": "OK", + "description": "Updated password successfully", "schema": { - "$ref": "#/definitions/dataset.Pack" + "type": "string" } }, "400": { @@ -1858,7 +854,7 @@ "application/json" ], "tags": [ - "Accounts" + "Public" ], "summary": "Register new user", "parameters": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 7f69762..4068388 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -108,103 +108,49 @@ info: title: PimpMyPack API version: "1.0" paths: - /accounts: - get: - description: Get all accounts - for admin use only - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dataset.Account' - "500": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: '[ADMIN] Get all accounts' - tags: - - Accounts + /login: post: consumes: - application/json - description: Create a new account - for admin use only + description: Logs in a user by providing username and password parameters: - - description: Account Information + - description: Username in: body - name: input + name: username required: true schema: - $ref: '#/definitions/dataset.Account' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/dataset.Account' - "400": - description: error - schema: - additionalProperties: true - type: object - "500": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: '[ADMIN] Create a new account' - tags: - - Accounts - /accounts/{id}: - delete: - description: Delete account by ID - for admin use only - parameters: - - description: Account ID - in: path - name: id + type: string + - description: Password + in: body + name: password required: true - type: integer + schema: + type: string produces: - application/json responses: "200": - description: Account deleted - schema: - type: string - "400": - description: error + description: token schema: - additionalProperties: true + additionalProperties: + type: string type: object - "500": - description: error + "403": + description: 'error: credentials are incorrect or token generation failed' schema: additionalProperties: true type: object - security: - - Bearer: [] - summary: '[ADMIN] Delete account by ID' + summary: User login tags: - - Accounts + - Public + /myaccount: get: - description: Get account by ID - for admin use only - parameters: - - description: Account ID - in: path - name: id - required: true - type: integer + description: Get information of the currently logged-in user produces: - application/json responses: "200": - description: OK + description: Account Information schema: $ref: '#/definitions/dataset.Account' "400": @@ -224,19 +170,14 @@ paths: type: object security: - Bearer: [] - summary: '[ADMIN] Get account by ID' + summary: Get account info tags: - Accounts put: consumes: - application/json - description: Update account by ID - for admin use only + description: Update information of the currently logged-in user parameters: - - description: Account ID - in: path - name: id - required: true - type: integer - description: Account Information in: body name: input @@ -249,607 +190,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dataset.Account' - "400": - description: error - schema: - additionalProperties: true - type: object - "500": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: '[ADMIN] Update account by ID' - tags: - - Accounts - /inventories: - get: - description: Retrieves a list of all inventories - for admin use only - produces: - - application/json - responses: - "200": - description: List of Inventories - schema: - items: - $ref: '#/definitions/dataset.Inventory' - type: array - "500": - description: Internal Server Error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: '[ADMIN] Get all inventories' - tags: - - Inventories - post: - consumes: - - application/json - description: Creates an inventory - for admin use only - parameters: - - description: Inventory - in: body - name: inventory - required: true - schema: - $ref: '#/definitions/dataset.Inventory' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/dataset.Inventory' - "400": - description: Invalid payload - schema: - additionalProperties: true - type: object - "500": - description: Internal Server Error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: '[ADMIN] Create an inventory' - tags: - - Inventories - /inventories/{id}: - delete: - description: Deletes an inventory by ID - for admin use only - parameters: - - description: Inventory ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: Inventory deleted - schema: - type: string - "400": - description: Invalid ID format - schema: - additionalProperties: true - type: object - "500": - description: Internal Server Error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: '[ADMIN] Delete an inventory by ID' - tags: - - Inventories - get: - description: Retrieves an inventory by ID - for admin use only - parameters: - - description: Inventory ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dataset.Inventory' - "400": - description: Invalid ID format - schema: - additionalProperties: true - type: object - "404": - description: Inventory not found - schema: - additionalProperties: true - type: object - "500": - description: Internal Server Error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: '[ADMIN] Get an inventory by ID' - tags: - - Inventories - put: - consumes: - - application/json - description: Updates an inventory by ID - for admin use only - parameters: - - description: Inventory ID - in: path - name: id - required: true - type: integer - - description: Inventory - in: body - name: inventory - required: true - schema: - $ref: '#/definitions/dataset.Inventory' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dataset.Inventory' - "400": - description: Invalid payload - schema: - additionalProperties: true - type: object - "500": - description: Internal Server Error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: '[ADMIN] Update an inventory by ID' - tags: - - Inventories - /login: - post: - consumes: - - application/json - description: Logs in a user by providing username and password - parameters: - - description: Username - in: body - name: username - required: true - schema: - type: string - - description: Password - in: body - name: password - required: true - schema: - type: string - produces: - - application/json - responses: - "200": - description: token - schema: - additionalProperties: - type: string - type: object - "403": - description: 'error: credentials are incorrect or token generation failed' - schema: - additionalProperties: true - type: object - summary: User login - tags: - - Accounts - /myaccount: - get: - description: Get information of the currently logged-in user - produces: - - application/json - responses: - "200": - description: Account Information - schema: - $ref: '#/definitions/dataset.Account' - "400": - description: error - schema: - additionalProperties: true - type: object - "404": - description: 'error: Account not found' - schema: - additionalProperties: true - type: object - "500": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Get account info - tags: - - Accounts - put: - consumes: - - application/json - description: Update information of the currently logged-in user - parameters: - - description: Account Information - in: body - name: input - required: true - schema: - $ref: '#/definitions/dataset.Account' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dataset.Account' - "400": - description: error - schema: - additionalProperties: true - type: object - "500": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Update account info - tags: - - Accounts - /myinventory: - get: - description: Retrieves a list of all inventories of the user - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/dataset.Inventory' - type: array - "500": - description: Internal Server Error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Get all inventories of the user - tags: - - Inventories - post: - consumes: - - application/json - description: Creates an inventory - parameters: - - description: Inventory - in: body - name: inventory - required: true - schema: - $ref: '#/definitions/dataset.Inventory' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/dataset.Inventory' - "400": - description: Invalid payload - schema: - additionalProperties: true - type: object - "500": - description: Internal Server Error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Create an inventory - tags: - - Inventories - /myinventory/{id}: - get: - description: Retrieves an inventory by ID - parameters: - - description: Inventory ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dataset.Inventory' - "400": - description: Invalid ID format - schema: - additionalProperties: true - type: object - "403": - description: This item does not belong to you - schema: - additionalProperties: true - type: object - "404": - description: Inventory not found - schema: - additionalProperties: true - type: object - "500": - description: Internal Server Error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Get an inventory by ID - tags: - - Inventories - put: - consumes: - - application/json - description: Updates an inventory by ID - parameters: - - description: Inventory ID - in: path - name: id - required: true - type: integer - - description: Inventory - in: body - name: inventory - required: true - schema: - $ref: '#/definitions/dataset.Inventory' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dataset.Inventory' - "400": - description: Invalid payload - schema: - additionalProperties: true - type: object - "403": - description: This item does not belong to you - schema: - additionalProperties: true - type: object - "500": - description: Internal Server Error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Update an inventory by ID - tags: - - Inventories - /mypack: - post: - consumes: - - application/json - description: Create a new pack - parameters: - - description: Pack - in: body - name: pack - required: true - schema: - $ref: '#/definitions/dataset.Pack' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/dataset.Pack' - "400": - description: error - schema: - additionalProperties: true - type: object - "500": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Create a new pack - tags: - - Packs - /mypack/{id}: - delete: - description: Delete a pack by ID - parameters: - - description: Pack ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: message - schema: - additionalProperties: - type: string - type: object - "400": - description: error - schema: - additionalProperties: true - type: object - "500": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Delete a pack by ID - tags: - - Packs - get: - description: Get pack by ID - parameters: - - description: Pack ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dataset.Pack' - "400": - description: error - schema: - additionalProperties: true - type: object - "404": - description: error - schema: - additionalProperties: true - type: object - "500": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Get pack by ID - tags: - - Packs - put: - consumes: - - application/json - description: Update a pack by ID - parameters: - - description: Pack ID - in: path - name: id - required: true - type: integer - - description: Pack - in: body - name: pack - required: true - schema: - $ref: '#/definitions/dataset.Pack' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dataset.Pack' - "400": - description: error - schema: - additionalProperties: true - type: object - "500": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Update a pack by ID - tags: - - Packs - /mypack/import: - post: - consumes: - - multipart/form-data - description: Import from lighterpack csv pack file - parameters: - - description: CSV file - in: formData - name: file - required: true - type: file - produces: - - application/json - responses: - "200": - description: message - schema: - additionalProperties: - type: string - type: object - "400": - description: error - schema: - additionalProperties: true - type: object - security: - - Bearer: [] - summary: Import from lighterpack csv pack file - tags: - - Packs - /mypackcontent: - post: - consumes: - - application/json - description: Create a new pack content - parameters: - - description: Pack Content - in: body - name: packcontent - required: true - schema: - $ref: '#/definitions/dataset.PackContent' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/dataset.PackContent' + $ref: '#/definitions/dataset.Account' "400": description: error schema: @@ -862,46 +203,69 @@ paths: type: object security: - Bearer: [] - summary: Create a new pack content + summary: Update account info tags: - - Packs - /mypackcontent/{id}: - delete: - description: Delete a pack content by ID - parameters: - - description: Pack Content ID - in: path - name: id - required: true - type: integer + - Accounts + /myinventory: + get: + description: Retrieves a list of all inventories of the user produces: - application/json responses: "200": - description: message + description: OK schema: - additionalProperties: - type: string + items: + $ref: '#/definitions/dataset.Inventory' + type: array + "500": + description: Internal Server Error + schema: + additionalProperties: true type: object + security: + - Bearer: [] + summary: Get all inventories of the user + tags: + - Inventories + post: + consumes: + - application/json + description: Creates an inventory + parameters: + - description: Inventory + in: body + name: inventory + required: true + schema: + $ref: '#/definitions/dataset.Inventory' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dataset.Inventory' "400": - description: error + description: Invalid payload schema: additionalProperties: true type: object "500": - description: error + description: Internal Server Error schema: additionalProperties: true type: object security: - Bearer: [] - summary: Delete a pack content by ID + summary: Create an inventory tags: - - Packs + - Inventories + /myinventory/{id}: get: - description: Get pack content by ID + description: Retrieves an inventory by ID parameters: - - description: Pack Content ID + - description: Inventory ID in: path name: id required: true @@ -912,123 +276,94 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dataset.PackContent' + $ref: '#/definitions/dataset.Inventory' "400": - description: error + description: Invalid ID format schema: additionalProperties: true type: object - "404": - description: error + "403": + description: This item does not belong to you schema: additionalProperties: true type: object - "500": - description: error + "404": + description: Inventory not found schema: additionalProperties: true type: object - security: - - Bearer: [] - summary: Get pack content by ID - tags: - - Packs - /mypacks: - get: - description: Get all packs - for admin use only - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/dataset.Pack' - type: array "500": - description: error + description: Internal Server Error schema: additionalProperties: true type: object security: - Bearer: [] - summary: '[ADMIN] Get all packs' + summary: Get an inventory by ID tags: - - Packs - /mypassword: + - Inventories put: consumes: - application/json - description: Update the password of the current logged-in user + description: Updates an inventory by ID parameters: - - description: Updated Password + - description: Inventory ID + in: path + name: id + required: true + type: integer + - description: Inventory in: body - name: password + name: inventory required: true schema: - type: string + $ref: '#/definitions/dataset.Inventory' produces: - application/json responses: "200": - description: Updated password successfully + description: OK schema: - type: string + $ref: '#/definitions/dataset.Inventory' "400": - description: error + description: Invalid payload schema: additionalProperties: true type: object - "500": - description: error + "403": + description: This item does not belong to you schema: additionalProperties: true type: object - security: - - Bearer: [] - summary: Update password - tags: - - Accounts - /packcontents: - get: - description: Get all pack contents - for admin use only - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/dataset.PackContent' - type: array "500": - description: error + description: Internal Server Error schema: additionalProperties: true type: object security: - Bearer: [] - summary: '[ADMIN] Get all pack contents' + summary: Update an inventory by ID tags: - - Packs + - Inventories + /mypack: post: consumes: - application/json - description: Create a new pack content - for admin use only + description: Create a new pack parameters: - - description: Pack Content + - description: Pack in: body - name: packcontent + name: pack required: true schema: - $ref: '#/definitions/dataset.PackContent' + $ref: '#/definitions/dataset.Pack' produces: - application/json responses: "201": description: Created schema: - $ref: '#/definitions/dataset.PackContent' + $ref: '#/definitions/dataset.Pack' "400": description: error schema: @@ -1041,14 +376,14 @@ paths: type: object security: - Bearer: [] - summary: '[ADMIN] Create a new pack content' + summary: Create a new pack tags: - Packs - /packcontents/{id}: + /mypack/{id}: delete: - description: Delete a pack content by ID - for admin use only + description: Delete a pack by ID parameters: - - description: Pack Content ID + - description: Pack ID in: path name: id required: true @@ -1074,13 +409,13 @@ paths: type: object security: - Bearer: [] - summary: '[ADMIN] Delete a pack content by ID' + summary: Delete a pack by ID tags: - Packs get: - description: Get pack content by ID - for admin use only + description: Get pack by ID parameters: - - description: Pack Content ID + - description: Pack ID in: path name: id required: true @@ -1091,7 +426,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dataset.PackContent' + $ref: '#/definitions/dataset.Pack' "400": description: error schema: @@ -1109,32 +444,32 @@ paths: type: object security: - Bearer: [] - summary: '[ADMIN] Get pack content by ID' + summary: Get pack by ID tags: - Packs put: consumes: - application/json - description: Update a pack content by ID - for admin use only + description: Update a pack by ID parameters: - - description: Pack Content ID + - description: Pack ID in: path name: id required: true type: integer - - description: Pack Content + - description: Pack in: body - name: packcontent + name: pack required: true schema: - $ref: '#/definitions/dataset.PackContent' + $ref: '#/definitions/dataset.Pack' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/dataset.PackContent' + $ref: '#/definitions/dataset.Pack' "400": description: error schema: @@ -1147,49 +482,58 @@ paths: type: object security: - Bearer: [] - summary: '[ADMIN] Update a pack content by ID' + summary: Update a pack by ID tags: - Packs - /packs: - get: - description: Get all packs - for admin use only + /mypack/import: + post: + consumes: + - multipart/form-data + description: Import from lighterpack csv pack file + parameters: + - description: CSV file + in: formData + name: file + required: true + type: file produces: - application/json responses: "200": - description: OK + description: message schema: - items: - $ref: '#/definitions/dataset.Pack' - type: array - "500": + additionalProperties: + type: string + type: object + "400": description: error schema: additionalProperties: true type: object security: - Bearer: [] - summary: '[ADMIN] Get all packs' + summary: Import from lighterpack csv pack file tags: - Packs + /mypackcontent: post: consumes: - application/json - description: Create a new pack - for admin use only + description: Create a new pack content parameters: - - description: Pack + - description: Pack Content in: body - name: pack + name: packcontent required: true schema: - $ref: '#/definitions/dataset.Pack' + $ref: '#/definitions/dataset.PackContent' produces: - application/json responses: "201": description: Created schema: - $ref: '#/definitions/dataset.Pack' + $ref: '#/definitions/dataset.PackContent' "400": description: error schema: @@ -1202,21 +546,32 @@ paths: type: object security: - Bearer: [] - summary: '[ADMIN] Create a new pack' + summary: Create a new pack content tags: - Packs - /packs/:id/packcontents: - get: - description: Get all pack contents - for admin use only + /mypackcontent/{id}: + delete: + description: Delete a pack content by ID + parameters: + - description: Pack Content ID + in: path + name: id + required: true + type: integer produces: - application/json responses: "200": - description: OK + description: message schema: - items: - $ref: '#/definitions/dataset.PackContent' - type: array + additionalProperties: + type: string + type: object + "400": + description: error + schema: + additionalProperties: true + type: object "500": description: error schema: @@ -1224,14 +579,13 @@ paths: type: object security: - Bearer: [] - summary: '[ADMIN] Get all pack contents' + summary: Delete a pack content by ID tags: - Packs - /packs/{id}: get: - description: Get pack by ID - for admin use only + description: Get pack content by ID parameters: - - description: Pack ID + - description: Pack Content ID in: path name: id required: true @@ -1242,7 +596,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dataset.Pack' + $ref: '#/definitions/dataset.PackContent' "400": description: error schema: @@ -1260,32 +614,28 @@ paths: type: object security: - Bearer: [] - summary: '[ADMIN] Get pack by ID' + summary: Get pack content by ID tags: - Packs + /mypassword: put: consumes: - application/json - description: Update a pack by ID - for admin use only + description: Update the password of the current logged-in user parameters: - - description: Pack ID - in: path - name: id - required: true - type: integer - - description: Pack + - description: Updated Password in: body - name: pack + name: password required: true schema: - $ref: '#/definitions/dataset.Pack' + type: string produces: - application/json responses: "200": - description: OK + description: Updated password successfully schema: - $ref: '#/definitions/dataset.Pack' + type: string "400": description: error schema: @@ -1298,9 +648,9 @@ paths: type: object security: - Bearer: [] - summary: '[ADMIN] Update a pack by ID' + summary: Update password tags: - - Packs + - Accounts /register: post: consumes: @@ -1329,5 +679,5 @@ paths: type: object summary: Register new user tags: - - Accounts + - Public swagger: "2.0" diff --git a/pkg/accounts/accounts.go b/pkg/accounts/accounts.go index 7e97aca..286f0e3 100644 --- a/pkg/accounts/accounts.go +++ b/pkg/accounts/accounts.go @@ -18,7 +18,7 @@ import ( // Register a new user account // @Summary Register new user // @Description Register a new user with username, password, email, firstname, and lastname -// @Tags Accounts +// @Tags Public // @Accept json // @Produce json // @Param input body dataset.RegisterInput true "Register Info" @@ -147,7 +147,7 @@ func updatePassword(user_id uint, updatedPassword string) error { // User login // @Summary User login // @Description Logs in a user by providing username and password -// @Tags Accounts +// @Tags Public // @Accept json // @Produce json // @Param username body string true "Username" @@ -283,7 +283,7 @@ func PutMyAccount(c *gin.Context) { // @Summary [ADMIN] Get all accounts // @Description Get all accounts - for admin use only // @Security Bearer -// @Tags Accounts +// @Tags Internal // @Produce json // @Success 200 {object} dataset.Account // @Failure 500 {object} map[string]interface{} "error" @@ -328,7 +328,7 @@ func returnAccounts() (*dataset.Accounts, error) { // @Summary [ADMIN] Get account by ID // @Description Get account by ID - for admin use only // @Security Bearer -// @Tags Accounts +// @Tags Internal // @Produce json // @Param id path int true "Account ID" // @Success 200 {object} dataset.Account @@ -381,7 +381,7 @@ func findAccountById(id uint) (*dataset.Account, error) { // @Summary [ADMIN] Create a new account // @Description Create a new account - for admin use only // @Security Bearer -// @Tags Accounts +// @Tags Internal // @Accept json // @Produce json // @Param input body dataset.Account true "Account Information" @@ -428,7 +428,7 @@ func insertAccount(a *dataset.Account) error { // @Summary [ADMIN] Update account by ID // @Description Update account by ID - for admin use only // @Security Bearer -// @Tags Accounts +// @Tags Internal // @Accept json // @Produce json // @Param id path int true "Account ID" @@ -483,7 +483,7 @@ func updateAccountById(id uint, a *dataset.Account) error { // @Summary [ADMIN] Delete account by ID // @Description Delete account by ID - for admin use only // @Security Bearer -// @Tags Accounts +// @Tags Internal // @Produce json // @Param id path int true "Account ID" // @Success 200 {string} string "Account deleted" diff --git a/pkg/inventories/inventories.go b/pkg/inventories/inventories.go index e3e4829..49f8e91 100644 --- a/pkg/inventories/inventories.go +++ b/pkg/inventories/inventories.go @@ -17,7 +17,7 @@ import ( // @Summary [ADMIN] Get all inventories // @Description Retrieves a list of all inventories - for admin use only // @Security Bearer -// @Tags Inventories +// @Tags Internal // @Produce json // @Success 200 {array} dataset.Inventory "List of Inventories" // @Failure 500 {object} map[string]interface{} "Internal Server Error" @@ -128,7 +128,7 @@ func returnInventoriesByUserID(user_id uint) (*dataset.Inventories, error) { // @Summary [ADMIN] Get an inventory by ID // @Description Retrieves an inventory by ID - for admin use only // @Security Bearer -// @Tags Inventories +// @Tags Internal // @Produce json // @Param id path int true "Inventory ID" // @Success 200 {object} dataset.Inventory @@ -225,7 +225,7 @@ func findInventoryById(id uint) (*dataset.Inventory, error) { // @Summary [ADMIN] Create an inventory // @Description Creates an inventory - for admin use only // @Security Bearer -// @Tags Inventories +// @Tags Internal // @Accept json // @Produce json // @Param inventory body dataset.Inventory true "Inventory" @@ -310,7 +310,7 @@ func InsertInventory(i *dataset.Inventory) error { // @Summary [ADMIN] Update an inventory by ID // @Description Updates an inventory by ID - for admin use only // @Security Bearer -// @Tags Inventories +// @Tags Internal // @Accept json // @Produce json // @Param id path int true "Inventory ID" @@ -423,7 +423,7 @@ func updateInventoryById(id uint, i *dataset.Inventory) error { // @Summary [ADMIN] Delete an inventory by ID // @Description Deletes an inventory by ID - for admin use only // @Security Bearer -// @Tags Inventories +// @Tags Internal // @Produce json // @Param id path int true "Inventory ID" // @Success 200 {object} string "Inventory deleted" diff --git a/pkg/packs/packs.go b/pkg/packs/packs.go index 9f99bbf..bb2dcec 100644 --- a/pkg/packs/packs.go +++ b/pkg/packs/packs.go @@ -21,7 +21,7 @@ import ( // @Summary [ADMIN] Get all packs // @Description Get all packs - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Produce json // @Success 200 {object} dataset.Packs // @Failure 500 {object} map[string]interface{} "error" @@ -79,7 +79,7 @@ func returnPacks() (dataset.Packs, error) { // @Summary [ADMIN] Get pack by ID // @Description Get pack by ID - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Produce json // @Param id path int true "Pack ID" // @Success 200 {object} dataset.Pack @@ -182,7 +182,7 @@ func findPackById(id uint) (*dataset.Pack, error) { // @Summary [ADMIN] Create a new pack // @Description Create a new pack - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Accept json // @Produce json // @Param pack body dataset.Pack true "Pack" @@ -266,7 +266,7 @@ func insertPack(p *dataset.Pack) error { // @Summary [ADMIN] Update a pack by ID // @Description Update a pack by ID - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Accept json // @Produce json // @Param id path int true "Pack ID" @@ -374,7 +374,7 @@ func updatePackById(id uint, p *dataset.Pack) error { // @Summary [ADMIN] Delete a pack by ID // @Description Delete a pack by ID - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Produce json // @Param id path int true "Pack ID" // @Success 200 {object} map[string]string "message" @@ -462,7 +462,7 @@ func deletePackById(id uint) error { // @Summary [ADMIN] Get all pack contents // @Description Get all pack contents - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Produce json // @Success 200 {object} dataset.PackContents // @Failure 500 {object} map[string]interface{} "error" @@ -508,7 +508,7 @@ func returnPackContents() (*dataset.PackContents, error) { // @Summary [ADMIN] Get pack content by ID // @Description Get pack content by ID - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Produce json // @Param id path int true "Pack Content ID" // @Success 200 {object} dataset.PackContent @@ -559,7 +559,7 @@ func findPackContentById(id uint) (*dataset.PackContent, error) { // @Summary [ADMIN] Create a new pack content // @Description Create a new pack content - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Accept json // @Produce json // @Param packcontent body dataset.PackContent true "Pack Content" @@ -656,7 +656,7 @@ func insertPackContent(pc *dataset.PackContent) error { // @Summary [ADMIN] Update a pack content by ID // @Description Update a pack content by ID - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Accept json // @Produce json // @Param id path int true "Pack Content ID" @@ -758,7 +758,7 @@ func updatePackContentByID(id uint, pc *dataset.PackContent) error { // @Summary [ADMIN] Delete a pack content by ID // @Description Delete a pack content by ID - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Produce json // @Param id path int true "Pack Content ID" // @Success 200 {object} map[string]string "message" @@ -849,7 +849,7 @@ func deletePackContentById(id uint) error { // @Summary [ADMIN] Get all pack contents // @Description Get all pack contents - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Produce json // @Success 200 {object} dataset.PackContents // @Failure 500 {object} map[string]interface{} "error" @@ -959,7 +959,7 @@ func returnPackContentsByPackID(id uint) (*dataset.PackContentWithItems, error) // @Summary [ADMIN] Get all packs // @Description Get all packs - for admin use only // @Security Bearer -// @Tags Packs +// @Tags Internal // @Produce json // @Success 200 {object} []dataset.Pack // @Failure 500 {object} map[string]interface{} "error"