optimize code

This commit is contained in:
MaxToby
2021-05-13 22:03:40 +08:00
parent 977035a853
commit d658701630
5 changed files with 105 additions and 19 deletions

7
example/sys/user.api Normal file
View File

@ -0,0 +1,7 @@
type (
RegisterReq {
Username string `json:"username"`
Password string `json:"password"`
Mobile string `json:"mobile"`
}
)

17
example/test.api Normal file
View File

@ -0,0 +1,17 @@
info(
title: "type title here"
desc: "type desc here"
author: "type author here"
email: "type email here"
version: "type version here"
)
import "sys/user.api"
service user-api {
@doc(
summary: 注册
)
@handler register
post /api/user/register (RegisterReq)
}

75
example/user.json Normal file
View File

@ -0,0 +1,75 @@
{
"swagger": "2.0",
"info": {
"title": "type title here",
"description": "type desc here",
"version": "type version here"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/api/user/register": {
"post": {
"summary": "注册",
"operationId": "register",
"responses": {
"200": {
"description": "A successful response.",
"schema": {}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RegisterReq"
}
}
],
"tags": [
"user-api"
]
}
}
},
"definitions": {
"RegisterReq": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
},
"mobile": {
"type": "string"
}
},
"title": "RegisterReq",
"required": [
"username",
"password",
"mobile"
]
}
},
"securityDefinitions": {
"apiKey": {
"type": "apiKey",
"description": "Enter JWT Bearer token **_only_**",
"name": "Authorization",
"in": "header"
}
}
}