chore: coded post req for create posts on db
All checks were successful
Backend ci / build (push) Successful in 7m43s

This commit is contained in:
d3m0k1d
2026-02-03 23:21:01 +03:00
parent 44406b02d3
commit 9b9d45e0a6
14 changed files with 254 additions and 67 deletions

View File

@@ -15,7 +15,7 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/v1/posts": {
"/posts": {
"get": {
"description": "Get all posts",
"consumes": [
@@ -34,14 +34,14 @@ const docTemplate = `{
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/storage.Post"
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
}
}
}
}
},
"post": {
"description": "Create post",
"description": "Create new post",
"consumes": [
"application/json"
],
@@ -52,17 +52,34 @@ const docTemplate = `{
"posts"
],
"summary": "Create post",
"parameters": [
{
"description": "Post data",
"name": "post",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/storage.Post"
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/api/v1/posts/{id}": {
"/posts/{id}": {
"get": {
"description": "Get post by id",
"consumes": [
@@ -79,7 +96,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/storage.Post"
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
}
}
}
@@ -100,7 +117,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/storage.Post"
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post"
}
}
}
@@ -121,7 +138,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/storage.Post"
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post"
}
}
}
@@ -129,7 +146,11 @@ const docTemplate = `{
}
},
"definitions": {
"storage.Post": {
"gin.H": {
"type": "object",
"additionalProperties": {}
},
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post": {
"type": "object",
"properties": {
"content": {
@@ -145,6 +166,28 @@ const docTemplate = `{
"type": "string"
}
}
},
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"title": {
"type": "string"
}
}
},
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"title": {
"type": "string"
}
}
}
}
}`