MSP-7967 add swagger
This commit is contained in:
1 parent
8221c78a5c
commit
e5a14a2729
4 files changed
+152
-70
No files matched your search
@@ -0,0 +1,9 @@
|
||||
package docs
|
||||
|
||||
import _ "embed"
|
||||
|
||||
// Embedded swagger files.
|
||||
var (
|
||||
//go:embed swagger.json
|
||||
SwaggerJson []byte
|
||||
)
|
||||
@@ -0,0 +1,140 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "Шаблон сервиса",
|
||||
"title": "isp-lock-service",
|
||||
"contact": {},
|
||||
"license": {
|
||||
"name": "GNU GPL v3.0"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"host": "localhost:9000",
|
||||
"basePath": "/api/isp-lock-service",
|
||||
"paths": {
|
||||
"/api/isp-lock-service/lock": {
|
||||
"post": {
|
||||
"description": "Возвращаем ключ для разблокировки",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"locker"
|
||||
],
|
||||
"summary": "выставляем лок на строку",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "строка для лока",
|
||||
"name": "key",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "число секунд после которых блокировка снимется автоматически",
|
||||
"name": "ttlInSec",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.LockResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/isp-lock-service/try_lock": {
|
||||
"post": {
|
||||
"description": "Пытаемся взять лок один раз. В отличие от Lock, не делает повторных попыток. При успехе возвращаем ключ для разблокировки.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"locker"
|
||||
],
|
||||
"summary": "однократная попытка взять лок без ретраев",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "строка для лока",
|
||||
"name": "key",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "число секунд после которых блокировка снимется автоматически",
|
||||
"name": "ttlInSec",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/domain.LockResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/isp-lock-service/unlock": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"locker"
|
||||
],
|
||||
"summary": "снимаем лок со строки",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "строка для лока",
|
||||
"name": "key",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "ключ для разблокировки, полученный из Lock",
|
||||
"name": "lockKey",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"domain.LockResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"lockKey": {
|
||||
"description": "nolint: tagliatelle",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
basePath: /api/isp-lock-service
|
||||
definitions:
|
||||
domain.LockResponse:
|
||||
properties:
|
||||
lockKey:
|
||||
description: 'nolint: tagliatelle'
|
||||
type: string
|
||||
type: object
|
||||
host: localhost:9000
|
||||
info:
|
||||
contact: {}
|
||||
description: Шаблон сервиса
|
||||
license:
|
||||
name: GNU GPL v3.0
|
||||
title: isp-lock-service
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/api/isp-lock-service/lock:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Возвращаем ключ для разблокировки
|
||||
parameters:
|
||||
- description: строка для лока
|
||||
in: query
|
||||
name: key
|
||||
required: true
|
||||
type: string
|
||||
- description: число секунд после которых блокировка снимется автоматически
|
||||
in: query
|
||||
name: ttlInSec
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/domain.LockResponse'
|
||||
summary: выставляем лок на строку
|
||||
tags:
|
||||
- locker
|
||||
/api/isp-lock-service/unlock:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: строка для лока
|
||||
in: query
|
||||
name: key
|
||||
required: true
|
||||
type: string
|
||||
- description: ключ для разблокировки, полученный из Lock
|
||||
in: query
|
||||
name: lockKey
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
summary: снимаем лок со строки
|
||||
tags:
|
||||
- locker
|
||||
swagger: "2.0"
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"isp-lock-service/routes"
|
||||
|
||||
"github.com/txix-open/isp-kit/bootstrap"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/shutdown"
|
||||
)
|
||||
|
||||
@@ -22,10 +23,9 @@ var (
|
||||
// @host localhost:9000
|
||||
// @BasePath /api/isp-lock-service
|
||||
|
||||
//go:generate swag init
|
||||
//go:generate rm -f docs/swagger.json docs/docs.go
|
||||
//go:generate swag init -pd -ot json -eot json
|
||||
func main() {
|
||||
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors())
|
||||
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors(), cluster.GrpcTransport)
|
||||
app := boot.App
|
||||
logger := app.Logger()
|
||||
|
||||
|
||||
Reference in new issue
Block a user