add language api docs

This commit is contained in:
2026-04-07 00:44:29 +02:00
parent cd7943cf6f
commit 2b1642f450
5 changed files with 2356 additions and 0 deletions

View File

@@ -24,6 +24,727 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/category/": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "List all categories",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Category"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Create a category",
"parameters": [
{
"description": "category",
"name": "category",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.CategoryRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Category"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
}
},
"/category/{id}": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Retreive a category",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this category.",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Category"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"put": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Update an existing category",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this category.",
"name": "id",
"in": "path",
"required": true
},
{
"description": "updated category",
"name": "category",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.CategoryRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Category"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"delete": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Delete an existing category",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this category.",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controllers.EmptyResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Partially update an existing category",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this category.",
"name": "id",
"in": "path",
"required": true
},
{
"description": "partially updated category",
"name": "category",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.CategoryRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Category"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
}
},
"/category/{id}/translation": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "List all category translations",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying the category.",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/models.CategoryTranslation"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Create a category translation",
"parameters": [
{
"description": "category translation",
"name": "category",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.CategoryTranslationRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.CategoryTranslation"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
}
},
"/category/{id}/translation/{id}": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Retreive a category translation",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying the category.",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "A unique integer value identifying the category translation.",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.CategoryTranslation"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"put": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Update an existing category translation",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this category.",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "A unique integer value identifying the category translation.",
"name": "id",
"in": "path",
"required": true
},
{
"description": "updated category translation",
"name": "category",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.CategoryTranslationRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.CategoryTranslation"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"delete": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Delete an existing category translation",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this category.",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "A unique integer value identifying the category translation.",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controllers.EmptyResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"category"
],
"summary": "Partially update an existing category translation",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this category.",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "A unique integer value identifying the category translation.",
"name": "id",
"in": "path",
"required": true
},
{
"description": "partially updated category translation",
"name": "category",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.CategoryTranslationRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.CategoryTranslation"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
}
},
"/lang/": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lang"
],
"summary": "List all languages",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Language"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lang"
],
"summary": "Create a language",
"parameters": [
{
"description": "language",
"name": "lang",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.LanguageRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Language"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
}
},
"/lang/{id}": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lang"
],
"summary": "Retreive a language",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this language.",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Language"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"put": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lang"
],
"summary": "Update an existing language",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this language.",
"name": "id",
"in": "path",
"required": true
},
{
"description": "updated language",
"name": "lang",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.LanguageRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Language"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"delete": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lang"
],
"summary": "Delete an existing language",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this language.",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controllers.EmptyResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
},
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"lang"
],
"summary": "Partially update an existing language",
"parameters": [
{
"type": "integer",
"description": "A unique integer value identifying this language.",
"name": "id",
"in": "path",
"required": true
},
{
"description": "partially updated language",
"name": "lang",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.LanguageRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Language"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httputil.HTTPError"
}
}
}
}
},
"/user/login": {
"post": {
"description": "Login user",
@@ -208,6 +929,18 @@ const docTemplate = `{
}
}
},
"gorm.DeletedAt": {
"type": "object",
"properties": {
"time": {
"type": "string"
},
"valid": {
"description": "Valid is true if Time is not NULL",
"type": "boolean"
}
}
},
"httputil.HTTPError": {
"type": "object",
"properties": {
@@ -220,6 +953,126 @@ const docTemplate = `{
"example": "status bad request"
}
}
},
"models.Category": {
"type": "object",
"properties": {
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"id": {
"type": "integer"
},
"translations": {
"type": "array",
"items": {
"$ref": "#/definitions/models.CategoryTranslation"
}
},
"updatedAt": {
"type": "string"
}
}
},
"models.CategoryRequest": {
"type": "object",
"required": [
"translations"
],
"properties": {
"translations": {
"type": "array",
"items": {
"$ref": "#/definitions/models.CategoryTranslationRequest"
}
}
}
},
"models.CategoryTranslation": {
"type": "object",
"properties": {
"categoryID": {
"type": "integer"
},
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"id": {
"type": "integer"
},
"languageID": {
"type": "integer"
},
"name": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"models.CategoryTranslationRequest": {
"type": "object",
"required": [
"languageId",
"name"
],
"properties": {
"languageId": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"models.Language": {
"type": "object",
"required": [
"code",
"name"
],
"properties": {
"code": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"models.LanguageRequest": {
"type": "object",
"required": [
"code",
"name"
],
"properties": {
"code": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"securityDefinitions": {