update api.go, auth.go, docs.go, handler.go, service.go, swagger.json, swagger.yaml

This commit is contained in:
redtea committed 2024-10-25 12:00:00 +03:00
1 parent 4c8b4e9fce
commit 362a6d1041
7 files changed
+1564

No files matched your search

+413
View File
@@ -0,0 +1,413 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {
"name": "API Support",
"email": "red.tea.dev@gmail.com"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/user": {
"put": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Create new user",
"parameters": [
{
"description": "User data in JSON",
"name": "user",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/esauth.User"
}
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
}
},
"/api/user/all": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Get ids of users",
"parameters": [
{
"type": "integer",
"description": "limit of users size",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "select offset",
"name": "start",
"in": "query",
"required": true
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"type": "integer"
}
}
}
}
}
},
"/api/user/count": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Get count of users",
"parameters": [
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.countResponse"
}
}
}
}
},
"/api/user/infinity-token": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Create infinity token (only for admin)",
"parameters": [
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.infinityTokenResponce"
}
}
}
}
},
"/api/user/self": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Get current user",
"parameters": [
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
},
"post": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Edit user",
"parameters": [
{
"description": "User description JSON",
"name": "user",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.editInput"
}
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
}
},
"/api/user/{user}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Get user by id",
"parameters": [
{
"type": "integer",
"description": "search user by id",
"name": "user",
"in": "path",
"required": true
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
},
"post": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Edit user by id",
"parameters": [
{
"type": "integer",
"description": "edit user by id",
"name": "user",
"in": "path",
"required": true
},
{
"description": "User data in JSON",
"name": "user",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/esauth.User"
}
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
},
"delete": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Delete user by id",
"parameters": [
{
"type": "integer",
"description": "id of user",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"definitions": {
"esauth.User": {
"type": "object",
"properties": {
"access": {
"type": "string"
},
"email": {
"type": "string"
},
"first_name": {
"type": "string"
},
"google_id": {
"type": "string"
},
"id": {
"type": "integer"
},
"last_name": {
"type": "string"
},
"picture_url": {
"type": "string"
},
"telegram_id": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"handler.countResponse": {
"type": "object",
"properties": {
"count": {
"type": "integer"
}
}
},
"handler.editInput": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"picture_url": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"handler.infinityTokenResponce": {
"type": "object"
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "auth.easystartup.su",
BasePath: "/api",
Schemes: []string{},
Title: "EasyStartup Auth",
Description: "Auth server for EasyStartup.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
+389
View File
@@ -0,0 +1,389 @@
{
"swagger": "2.0",
"info": {
"description": "Auth server for EasyStartup.",
"title": "EasyStartup Auth",
"contact": {
"name": "API Support",
"email": "red.tea.dev@gmail.com"
},
"version": "1.0"
},
"host": "auth.easystartup.su",
"basePath": "/api",
"paths": {
"/api/user": {
"put": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Create new user",
"parameters": [
{
"description": "User data in JSON",
"name": "user",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/esauth.User"
}
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
}
},
"/api/user/all": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Get ids of users",
"parameters": [
{
"type": "integer",
"description": "limit of users size",
"name": "limit",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "select offset",
"name": "start",
"in": "query",
"required": true
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"type": "integer"
}
}
}
}
}
},
"/api/user/count": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Get count of users",
"parameters": [
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.countResponse"
}
}
}
}
},
"/api/user/infinity-token": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Create infinity token (only for admin)",
"parameters": [
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.infinityTokenResponce"
}
}
}
}
},
"/api/user/self": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Get current user",
"parameters": [
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
},
"post": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Edit user",
"parameters": [
{
"description": "User description JSON",
"name": "user",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.editInput"
}
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
}
},
"/api/user/{user}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Get user by id",
"parameters": [
{
"type": "integer",
"description": "search user by id",
"name": "user",
"in": "path",
"required": true
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
},
"post": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Edit user by id",
"parameters": [
{
"type": "integer",
"description": "edit user by id",
"name": "user",
"in": "path",
"required": true
},
{
"description": "User data in JSON",
"name": "user",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/esauth.User"
}
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/esauth.User"
}
}
}
},
"delete": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Delete user by id",
"parameters": [
{
"type": "integer",
"description": "id of user",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "JWT Bearer token (authorization)",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"definitions": {
"esauth.User": {
"type": "object",
"properties": {
"access": {
"type": "string"
},
"email": {
"type": "string"
},
"first_name": {
"type": "string"
},
"google_id": {
"type": "string"
},
"id": {
"type": "integer"
},
"last_name": {
"type": "string"
},
"picture_url": {
"type": "string"
},
"telegram_id": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"handler.countResponse": {
"type": "object",
"properties": {
"count": {
"type": "integer"
}
}
},
"handler.editInput": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"picture_url": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"handler.infinityTokenResponce": {
"type": "object"
}
}
}
+255
View File
@@ -0,0 +1,255 @@
basePath: /api
definitions:
esauth.User:
properties:
access:
type: string
email:
type: string
first_name:
type: string
google_id:
type: string
id:
type: integer
last_name:
type: string
picture_url:
type: string
telegram_id:
type: string
username:
type: string
type: object
handler.countResponse:
properties:
count:
type: integer
type: object
handler.editInput:
properties:
email:
type: string
first_name:
type: string
last_name:
type: string
picture_url:
type: string
username:
type: string
type: object
handler.infinityTokenResponce:
type: object
host: auth.easystartup.su
info:
contact:
email: red.tea.dev@gmail.com
name: API Support
description: Auth server for EasyStartup.
title: EasyStartup Auth
version: "1.0"
paths:
/api/user:
put:
parameters:
- description: User data in JSON
in: body
name: user
required: true
schema:
$ref: '#/definitions/esauth.User'
- description: JWT Bearer token (authorization)
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/esauth.User'
summary: Create new user
tags:
- user
/api/user/{user}:
delete:
parameters:
- description: id of user
in: path
name: id
required: true
type: integer
- description: JWT Bearer token (authorization)
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
summary: Delete user by id
tags:
- user
get:
parameters:
- description: search user by id
in: path
name: user
required: true
type: integer
- description: JWT Bearer token (authorization)
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/esauth.User'
summary: Get user by id
tags:
- user
post:
parameters:
- description: edit user by id
in: path
name: user
required: true
type: integer
- description: User data in JSON
in: body
name: user
required: true
schema:
$ref: '#/definitions/esauth.User'
- description: JWT Bearer token (authorization)
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/esauth.User'
summary: Edit user by id
tags:
- user
/api/user/all:
get:
parameters:
- description: limit of users size
in: query
name: limit
required: true
type: integer
- description: select offset
in: query
name: start
required: true
type: integer
- description: JWT Bearer token (authorization)
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
type: integer
type: array
summary: Get ids of users
tags:
- user
/api/user/count:
get:
parameters:
- description: JWT Bearer token (authorization)
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handler.countResponse'
summary: Get count of users
tags:
- user
/api/user/infinity-token:
get:
parameters:
- description: JWT Bearer token (authorization)
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handler.infinityTokenResponce'
summary: Create infinity token (only for admin)
tags:
- user
/api/user/self:
get:
parameters:
- description: JWT Bearer token (authorization)
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/esauth.User'
summary: Get current user
tags:
- user
post:
parameters:
- description: User description JSON
in: body
name: user
required: true
schema:
$ref: '#/definitions/handler.editInput'
- description: JWT Bearer token (authorization)
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/esauth.User'
summary: Edit user
tags:
- user
swagger: "2.0"