-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from veops/dev
feat: add swagger api doc
- Loading branch information
Showing
11 changed files
with
999 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
.PHONY: lint | ||
lint: ## Apply go lint check | ||
@golangci-lint run --timeout 10m ./... | ||
.PHONY: lint | ||
|
||
.PHONY: swagger | ||
swagger: | ||
swag fmt && swag init --parseInternal --pd -p snakecase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,337 @@ | ||
// 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": {}, | ||
"version": "{{.Version}}" | ||
}, | ||
"host": "{{.Host}}", | ||
"basePath": "{{.BasePath}}", | ||
"paths": { | ||
"/v1/message": { | ||
"post": { | ||
"description": "send a new message\nhttps://github.com/veops/messenger?tab=readme-ov-file#发送消息", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"send" | ||
], | ||
"parameters": [ | ||
{ | ||
"description": " ", | ||
"name": "body", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"$ref": "#/definitions/send.message" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "a map with msg info, eg. {msg:ok}", | ||
"schema": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/v1/senders": { | ||
"put": { | ||
"description": "push a conf to overwrite(POST), update(PUT) or delete(DELETE) existing conf of senders\nhttps://github.com/veops/messenger?tab=readme-ov-file#更新配置", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"conf" | ||
], | ||
"parameters": [ | ||
{ | ||
"description": "senders config, eg. {wechatBot: [{name: yourSenderName, url: https://xxx}]}", | ||
"name": "body", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "a map with msg info, eg. {msg:ok}", | ||
"schema": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"post": { | ||
"description": "push a conf to overwrite(POST), update(PUT) or delete(DELETE) existing conf of senders\nhttps://github.com/veops/messenger?tab=readme-ov-file#更新配置", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"conf" | ||
], | ||
"parameters": [ | ||
{ | ||
"description": "senders config, eg. {wechatBot: [{name: yourSenderName, url: https://xxx}]}", | ||
"name": "body", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "a map with msg info, eg. {msg:ok}", | ||
"schema": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"delete": { | ||
"description": "push a conf to overwrite(POST), update(PUT) or delete(DELETE) existing conf of senders\nhttps://github.com/veops/messenger?tab=readme-ov-file#更新配置", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"conf" | ||
], | ||
"parameters": [ | ||
{ | ||
"description": "senders config, eg. {wechatBot: [{name: yourSenderName, url: https://xxx}]}", | ||
"name": "body", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "a map with msg info, eg. {msg:ok}", | ||
"schema": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/v1/uid/getbyphone": { | ||
"post": { | ||
"description": "get user's uid by he or she's phone number\nhttps://github.com/veops/messenger?tab=readme-ov-file#查询用户ID", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"send" | ||
], | ||
"parameters": [ | ||
{ | ||
"description": " ", | ||
"name": "body", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"$ref": "#/definitions/send.getUIDByPhoneReq" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "a map with phone as key and uid as value", | ||
"schema": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"send.getUIDByPhoneReq": { | ||
"type": "object", | ||
"required": [ | ||
"phone", | ||
"sender" | ||
], | ||
"properties": { | ||
"phone": { | ||
"type": "string", | ||
"example": "133123456789" | ||
}, | ||
"sender": { | ||
"type": "string", | ||
"example": "myWechatBot" | ||
} | ||
} | ||
}, | ||
"send.message": { | ||
"type": "object", | ||
"required": [ | ||
"content", | ||
"msgtype", | ||
"sender" | ||
], | ||
"properties": { | ||
"at_mobiles": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"example": [ | ||
"133123456789" | ||
] | ||
}, | ||
"ats": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"example": [ | ||
"xxx" | ||
] | ||
}, | ||
"ccs": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"example": [ | ||
"" | ||
] | ||
}, | ||
"content": { | ||
"type": "string", | ||
"example": "this is a text content" | ||
}, | ||
"extra": { | ||
"type": "string", | ||
"example": "{\"enable_duplicate_check\": 1,\"duplicate_check_interval\": 1800}" | ||
}, | ||
"msgtype": { | ||
"type": "string", | ||
"example": "text" | ||
}, | ||
"sender": { | ||
"type": "string", | ||
"example": "myWechatBot" | ||
}, | ||
"simple": { | ||
"type": "boolean", | ||
"example": true | ||
}, | ||
"sync": { | ||
"type": "boolean", | ||
"example": true | ||
}, | ||
"title": { | ||
"type": "string", | ||
"example": "" | ||
}, | ||
"tos": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"example": [ | ||
"" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"externalDocs": { | ||
"description": "Messenger README", | ||
"url": "https://github.com/veops/messenger?tab=readme-ov-file#messenger" | ||
} | ||
}` | ||
|
||
// SwaggerInfo holds exported Swagger Info so clients can modify it | ||
var SwaggerInfo = &swag.Spec{ | ||
Version: "", | ||
Host: "", | ||
BasePath: "", | ||
Schemes: []string{}, | ||
Title: "", | ||
Description: "", | ||
InfoInstanceName: "swagger", | ||
SwaggerTemplate: docTemplate, | ||
LeftDelim: "{{", | ||
RightDelim: "}}", | ||
} | ||
|
||
func init() { | ||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) | ||
} |
Oops, something went wrong.