optimize code
This commit is contained in:
		
							
								
								
									
										7
									
								
								example/sys/user.api
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								example/sys/user.api
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										17
									
								
								example/test.api
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										75
									
								
								example/user.json
									
									
									
									
									
										Normal 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" | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										7
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								go.mod
									
									
									
									
									
								
							| @@ -1,13 +1,10 @@ | ||||
| module github.com/zeromicro/goctl-swagger | ||||
|  | ||||
| go 1.15 | ||||
| go 1.16 | ||||
|  | ||||
| require ( | ||||
| 	github.com/antlr/antlr4 v0.0.0-20210319025552-3590d4d5e18c // indirect | ||||
| 	github.com/go-sql-driver/mysql v1.6.0 // indirect | ||||
| 	github.com/grpc-ecosystem/grpc-gateway v1.14.3 | ||||
| 	github.com/iancoleman/strcase v0.1.3 // indirect | ||||
| 	github.com/tal-tech/go-zero v1.1.6 | ||||
| 	github.com/tal-tech/go-zero v1.1.8-0.20210513104205-9f6a574f9766 | ||||
| 	github.com/urfave/cli/v2 v2.3.0 | ||||
| 	go.uber.org/automaxprocs v1.4.0 // indirect | ||||
| 	golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be | ||||
|   | ||||
							
								
								
									
										18
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								go.sum
									
									
									
									
									
								
							| @@ -9,11 +9,6 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF | ||||
| github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= | ||||
| github.com/alicebob/miniredis/v2 v2.14.1/go.mod h1:uS970Sw5Gs9/iK3yBg0l9Uj9s25wXxSpQUE9EaJ/Blg= | ||||
| github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= | ||||
| github.com/antlr/antlr4 v0.0.0-20210105212045-464bcbc32de2/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y= | ||||
| github.com/antlr/antlr4 v0.0.0-20210114010855-d34d2e1c271a h1:gXj02obcEEw9NVyvbn4PGQn1pPX3s7rCetf3Pzue/6U= | ||||
| github.com/antlr/antlr4 v0.0.0-20210114010855-d34d2e1c271a/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y= | ||||
| github.com/antlr/antlr4 v0.0.0-20210319025552-3590d4d5e18c h1:qGOWI+NNhKcTXy3JuHGXgCOfcz77a1zVeW4ChjluDCA= | ||||
| github.com/antlr/antlr4 v0.0.0-20210319025552-3590d4d5e18c/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y= | ||||
| github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= | ||||
| github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= | ||||
| github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= | ||||
| @@ -39,7 +34,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= | ||||
| github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | ||||
| github.com/emicklei/proto v1.9.0 h1:l0QiNT6Qs7Yj0Mb4X6dnWBQer4ebei2BFcgQLbGqUDc= | ||||
| github.com/emicklei/proto v1.9.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= | ||||
| github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= | ||||
| github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= | ||||
| @@ -61,8 +55,6 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V | ||||
| github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= | ||||
| github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= | ||||
| github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= | ||||
| github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= | ||||
| github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= | ||||
| github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= | ||||
| github.com/go-xorm/builder v0.3.4/go.mod h1:KxkQkNN1DpPKTedxXyTQcmH+rXfvk4LZ9SOOBoZBAxw= | ||||
| github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM= | ||||
| @@ -109,8 +101,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.14.3/go.mod h1:6CwZWGDSPRJidgKAtJVvND6 | ||||
| github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= | ||||
| github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= | ||||
| github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= | ||||
| github.com/iancoleman/strcase v0.1.3 h1:dJBk1m2/qjL1twPLf68JND55vvivMupZ4wIzE8CTdBw= | ||||
| github.com/iancoleman/strcase v0.1.3/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= | ||||
| github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= | ||||
| github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= | ||||
| github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= | ||||
| @@ -198,8 +188,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV | ||||
| github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||||
| github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= | ||||
| github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||||
| github.com/tal-tech/go-zero v1.1.6 h1:Xnbx0t10zzT2dcbpWOxmhsSu3DOkYwj604BSdfSkJlM= | ||||
| github.com/tal-tech/go-zero v1.1.6/go.mod h1:LbN0C7/rbl2+LUWTSUYx5leXmgedeMWjt1jc3/8/zFA= | ||||
| github.com/tal-tech/go-zero v1.1.8-0.20210513104205-9f6a574f9766 h1:/cRynymJ9ZwlmPpMRt+WrZwwn56pNcG/xZhzENvQrJ8= | ||||
| github.com/tal-tech/go-zero v1.1.8-0.20210513104205-9f6a574f9766/go.mod h1:BEylLQnv5moldpMT1lH3kUoMEcdaIp+r9Lgp+41dXxg= | ||||
| github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= | ||||
| github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= | ||||
| github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= | ||||
| @@ -208,14 +198,14 @@ github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX | ||||
| github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= | ||||
| github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= | ||||
| github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= | ||||
| github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 h1:zzrxE1FKn5ryBNl9eKOeqQ58Y/Qpo3Q9QNxKHX5uzzQ= | ||||
| github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2/go.mod h1:hzfGeIUDq/j97IG+FhNqkowIyEcD88LrW6fyU3K3WqY= | ||||
| github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||
| github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ= | ||||
| github.com/zeromicro/antlr v0.0.1 h1:CQpIn/dc0pUjgGQ81y98s/NGOm2Hfru2NNio2I9mQgk= | ||||
| github.com/zeromicro/antlr v0.0.1/go.mod h1:nfpjEwFR6Q4xGDJMcZnCL9tEfQRgszMwu3rDz2Z+p5M= | ||||
| go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= | ||||
| go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698/go.mod h1:YoUyTScD3Vcv2RBm3eGVOq7i1ULiz3OuXoQFWOirmAM= | ||||
| go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= | ||||
| go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0= | ||||
| go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA= | ||||
| go.uber.org/automaxprocs v1.4.0 h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0= | ||||
| go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q= | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 MaxToby
					MaxToby