Skip to content

Generate Visual Studio Code REST Client plugin files for zero-api

Notifications You must be signed in to change notification settings

zeromicro/goctl-restclient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1. Main Features

* 根据 api 文件生成 [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) 所需要的rest文件
* 支持 api default 即默认值
* POST,PUT 暂仅支持json请求结构体

2. Installation

通过如下命令安装:

GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go install github.com/zeromicro/goctl-restclient

3. 快速开始

* 1.create the API file, like user.api, 
 type (
     
     //注册请求结构
     RegisterReq {
         Username string `json:"username,default=admin"`
         Password string `json:"password,default=admin123"`
         Mobile string `json:"mobile"`
     }

     LoginReq {
         Username string `json:"username"` //测试
         Password string `json:"password"`//测试2
     }
     UserInfoReq {
         Id string `path:"id"`
     }

     UserInfoReply {
         Name string `json:"name"`
         Age int `json:"age"`
         Birthday string `json:"birthday"`
         Description string `json:"description"`
         Tag []string `json:"tag"`
     }

     UserSearchReq {
         KeyWord string `form:"keyWord"` // 关键词
     }
 )


 service user-api {
     @doc(
         summary: 注册
     )
     @handler register
     post /api/user/register (RegisterReq)

     @doc(
         summary: 登录
     )
     @handler login
     post /api/user/login (LoginReq)

     @doc(
         summary: 获取用户信息
     )
     @handler getUserInfo
     get /api/user/:id (UserInfoReq) returns (UserInfoReply)

     @doc(
         summary: 用户搜索
     )
     @handler searchUser
     get /api/user/search (UserSearchReq) returns (UserInfoReply)
 }
    1. Generate REST client file
     goctl api plugin -plugin goctl-restclient="-filename user.rest" -api user.api -dir .
    1. Request Variables
    • touch .env
        baseUrl = http://127.0.0.1:8921

About

Generate Visual Studio Code REST Client plugin files for zero-api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published