Update auth swagger

This commit is contained in:
Zoe Roux 2025-07-18 22:36:21 +02:00
parent 61b6eb0c6e
commit 30dd1e0b96
2 changed files with 456 additions and 2 deletions

View File

@ -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": {

View File

@ -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": {