From 30dd1e0b967ffc031b5bfa196e3db131b3e9c5e3 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 18 Jul 2025 22:36:21 +0200 Subject: [PATCH] Update auth swagger --- auth/docs/docs.go | 229 ++++++++++++++++++++++++++++++++++++++++- auth/docs/swagger.json | 229 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 456 insertions(+), 2 deletions(-) diff --git a/auth/docs/docs.go b/auth/docs/docs.go index 2b9f7a65..b220190e 100644 --- a/auth/docs/docs.go +++ b/auth/docs/docs.go @@ -49,7 +49,7 @@ const docTemplate = `{ "Token": [] } ], - "description": "Convert a session token to a short lived JWT.", + "description": "Convert a session token or an API key to a short lived JWT.", "produces": [ "application/json" ], @@ -79,6 +79,126 @@ const docTemplate = `{ } } }, + "/keys": { + "get": { + "security": [ + { + "Jwt": [ + "apikeys.read" + ] + } + ], + "description": "List all api keys", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "apikeys" + ], + "summary": "List API keys", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.Page-main_ApiKey" + } + } + } + }, + "post": { + "security": [ + { + "Jwt": [ + "apikeys.write" + ] + } + ], + "description": "Create a new API key", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "apikeys" + ], + "summary": "Create API key", + "parameters": [ + { + "description": "Api key info", + "name": "key", + "in": "body", + "schema": { + "$ref": "#/definitions/main.ApiKeyDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/main.ApiKeyWToken" + } + }, + "409": { + "description": "Duplicated api key", + "schema": { + "$ref": "#/definitions/main.KError" + } + }, + "422": { + "description": "Invalid create body", + "schema": { + "$ref": "#/definitions/main.KError" + } + } + } + }, + "delete": { + "security": [ + { + "Jwt": [ + "apikeys.write" + ] + } + ], + "description": "Delete an existing API key", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "apikeys" + ], + "summary": "Delete API key", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.ApiKey" + } + }, + "404": { + "description": "Invalid id", + "schema": { + "$ref": "#/definitions/main.KError" + } + }, + "422": { + "description": "Invalid id format", + "schema": { + "$ref": "#/definitions/main.KError" + } + } + } + } + }, "/sessions": { "post": { "description": "Login to your account and open a session", @@ -563,6 +683,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/main.KError" } + }, + "422": { + "description": "Invalid id format", + "schema": { + "$ref": "#/definitions/main.KError" + } } } }, @@ -626,6 +752,88 @@ const docTemplate = `{ } }, "definitions": { + "main.ApiKey": { + "type": "object", + "properties": { + "claims": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "isAdmin": " true" + } + }, + "createAt": { + "type": "string", + "example": "2025-03-29T18:20:05.267Z" + }, + "id": { + "type": "string", + "example": "e05089d6-9179-4b5b-a63e-94dd5fc2a397" + }, + "lastUsed": { + "type": "string", + "example": "2025-03-29T18:20:05.267Z" + }, + "name": { + "type": "string", + "example": "myapp" + } + } + }, + "main.ApiKeyDto": { + "type": "object", + "properties": { + "claims": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "isAdmin": " true" + } + }, + "name": { + "type": "string", + "example": "myapp" + } + } + }, + "main.ApiKeyWToken": { + "type": "object", + "properties": { + "claims": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "isAdmin": " true" + } + }, + "createAt": { + "type": "string", + "example": "2025-03-29T18:20:05.267Z" + }, + "id": { + "type": "string", + "example": "e05089d6-9179-4b5b-a63e-94dd5fc2a397" + }, + "lastUsed": { + "type": "string", + "example": "2025-03-29T18:20:05.267Z" + }, + "name": { + "type": "string", + "example": "myapp" + }, + "token": { + "type": "string", + "example": "myapp-lyHzTYm9yi+pkEv3m2tamAeeK7Dj7N3QRP7xv7dPU5q9MAe8tU4ySwYczE0RaMr4fijsA==" + } + } + }, "main.EditPasswordDto": { "type": "object", "required": [ @@ -762,6 +970,25 @@ const docTemplate = `{ } } }, + "main.Page-main_ApiKey": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/main.ApiKey" + } + }, + "next": { + "type": "string", + "example": "https://kyoo.zoriya.dev/auth/users?after=aoeusth" + }, + "this": { + "type": "string", + "example": "https://kyoo.zoriya.dev/auth/users" + } + } + }, "main.Page-main_User": { "type": "object", "properties": { diff --git a/auth/docs/swagger.json b/auth/docs/swagger.json index 367b80ea..fb41edc9 100644 --- a/auth/docs/swagger.json +++ b/auth/docs/swagger.json @@ -43,7 +43,7 @@ "Token": [] } ], - "description": "Convert a session token to a short lived JWT.", + "description": "Convert a session token or an API key to a short lived JWT.", "produces": [ "application/json" ], @@ -73,6 +73,126 @@ } } }, + "/keys": { + "get": { + "security": [ + { + "Jwt": [ + "apikeys.read" + ] + } + ], + "description": "List all api keys", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "apikeys" + ], + "summary": "List API keys", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.Page-main_ApiKey" + } + } + } + }, + "post": { + "security": [ + { + "Jwt": [ + "apikeys.write" + ] + } + ], + "description": "Create a new API key", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "apikeys" + ], + "summary": "Create API key", + "parameters": [ + { + "description": "Api key info", + "name": "key", + "in": "body", + "schema": { + "$ref": "#/definitions/main.ApiKeyDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/main.ApiKeyWToken" + } + }, + "409": { + "description": "Duplicated api key", + "schema": { + "$ref": "#/definitions/main.KError" + } + }, + "422": { + "description": "Invalid create body", + "schema": { + "$ref": "#/definitions/main.KError" + } + } + } + }, + "delete": { + "security": [ + { + "Jwt": [ + "apikeys.write" + ] + } + ], + "description": "Delete an existing API key", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "apikeys" + ], + "summary": "Delete API key", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.ApiKey" + } + }, + "404": { + "description": "Invalid id", + "schema": { + "$ref": "#/definitions/main.KError" + } + }, + "422": { + "description": "Invalid id format", + "schema": { + "$ref": "#/definitions/main.KError" + } + } + } + } + }, "/sessions": { "post": { "description": "Login to your account and open a session", @@ -557,6 +677,12 @@ "schema": { "$ref": "#/definitions/main.KError" } + }, + "422": { + "description": "Invalid id format", + "schema": { + "$ref": "#/definitions/main.KError" + } } } }, @@ -620,6 +746,88 @@ } }, "definitions": { + "main.ApiKey": { + "type": "object", + "properties": { + "claims": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "isAdmin": " true" + } + }, + "createAt": { + "type": "string", + "example": "2025-03-29T18:20:05.267Z" + }, + "id": { + "type": "string", + "example": "e05089d6-9179-4b5b-a63e-94dd5fc2a397" + }, + "lastUsed": { + "type": "string", + "example": "2025-03-29T18:20:05.267Z" + }, + "name": { + "type": "string", + "example": "myapp" + } + } + }, + "main.ApiKeyDto": { + "type": "object", + "properties": { + "claims": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "isAdmin": " true" + } + }, + "name": { + "type": "string", + "example": "myapp" + } + } + }, + "main.ApiKeyWToken": { + "type": "object", + "properties": { + "claims": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "isAdmin": " true" + } + }, + "createAt": { + "type": "string", + "example": "2025-03-29T18:20:05.267Z" + }, + "id": { + "type": "string", + "example": "e05089d6-9179-4b5b-a63e-94dd5fc2a397" + }, + "lastUsed": { + "type": "string", + "example": "2025-03-29T18:20:05.267Z" + }, + "name": { + "type": "string", + "example": "myapp" + }, + "token": { + "type": "string", + "example": "myapp-lyHzTYm9yi+pkEv3m2tamAeeK7Dj7N3QRP7xv7dPU5q9MAe8tU4ySwYczE0RaMr4fijsA==" + } + } + }, "main.EditPasswordDto": { "type": "object", "required": [ @@ -756,6 +964,25 @@ } } }, + "main.Page-main_ApiKey": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/main.ApiKey" + } + }, + "next": { + "type": "string", + "example": "https://kyoo.zoriya.dev/auth/users?after=aoeusth" + }, + "this": { + "type": "string", + "example": "https://kyoo.zoriya.dev/auth/users" + } + } + }, "main.Page-main_User": { "type": "object", "properties": {