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"
}
}
}
}
}`

View File

@@ -4,7 +4,7 @@
"contact": {}
},
"paths": {
"/api/v1/posts": {
"/posts": {
"get": {
"description": "Get all posts",
"consumes": [
@@ -23,14 +23,14 @@
"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"
],
@@ -41,17 +41,34 @@
"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": [
@@ -68,7 +85,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/storage.Post"
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq"
}
}
}
@@ -89,7 +106,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/storage.Post"
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post"
}
}
}
@@ -110,7 +127,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/storage.Post"
"$ref": "#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post"
}
}
}
@@ -118,7 +135,11 @@
}
},
"definitions": {
"storage.Post": {
"gin.H": {
"type": "object",
"additionalProperties": {}
},
"gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post": {
"type": "object",
"properties": {
"content": {
@@ -134,6 +155,28 @@
"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"
}
}
}
}
}

View File

@@ -1,5 +1,8 @@
definitions:
storage.Post:
gin.H:
additionalProperties: {}
type: object
gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post:
properties:
content:
type: string
@@ -10,10 +13,24 @@ definitions:
title:
type: string
type: object
gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate:
properties:
content:
type: string
title:
type: string
type: object
gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq:
properties:
content:
type: string
title:
type: string
type: object
info:
contact: {}
paths:
/api/v1/posts:
/posts:
get:
consumes:
- application/json
@@ -25,7 +42,7 @@ paths:
description: OK
schema:
items:
$ref: '#/definitions/storage.Post'
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq'
type: array
summary: Get all posts
tags:
@@ -33,18 +50,29 @@ paths:
post:
consumes:
- application/json
description: Create post
description: Create new post
parameters:
- description: Post data
in: body
name: post
required: true
schema:
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostCreate'
produces:
- application/json
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'
summary: Create post
tags:
- posts
/api/v1/posts/{id}:
/posts/{id}:
delete:
consumes:
- application/json
@@ -55,7 +83,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/storage.Post'
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post'
summary: Delete post
tags:
- posts
@@ -69,7 +97,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/storage.Post'
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.PostReq'
summary: Get post by id
tags:
- posts
@@ -83,7 +111,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/storage.Post'
$ref: '#/definitions/gitea_d3m0k1d_ru_d3m0k1d_d3m0k1d_ru_backend_internal_storage.Post'
summary: Update post
tags:
- posts