├── test ├── expected │ ├── go │ │ ├── .keep │ │ ├── apisvr │ │ │ ├── Empty.go │ │ │ ├── EnvListRequest.go │ │ │ ├── TagListRequest.go │ │ │ ├── AuthError.go │ │ │ ├── BindError.go │ │ │ ├── EnvListResponse.go │ │ │ ├── GenericError.go │ │ │ ├── KeyListResponse.go │ │ │ ├── TagListResponse.go │ │ │ ├── ProductListRequest.go │ │ │ ├── ValidateError.go │ │ │ ├── KeyValueResponse.go │ │ │ ├── ProductListResponse.go │ │ │ ├── KeyValueListResponse.go │ │ │ ├── KVHistoryResponse.go │ │ │ ├── Env.go │ │ │ ├── Tag.go │ │ │ ├── Error.go │ │ │ ├── KeyListRequest.go │ │ │ ├── Product.go │ │ │ ├── KVHistoryRequest.go │ │ │ ├── KeyValueListRequest.go │ │ │ ├── FieldError.go │ │ │ ├── KeyValueRequest.go │ │ │ ├── ValidateErrorType.go │ │ │ ├── UpdateServiceRequest.go │ │ │ ├── UpdateServiceResponse.go │ │ │ ├── UploadProtoFileRequest.go │ │ │ ├── UploadProtoFileResponse.go │ │ │ ├── SearchKeyValueListRequest.go │ │ │ ├── ServiceListRequest.go │ │ │ ├── ServiceListResponse.go │ │ │ ├── KVHistoryItem.go │ │ │ ├── RegisterServiceResponse.go │ │ │ ├── Key.go │ │ │ ├── CommonError.go │ │ │ └── ErrorCode.go │ │ ├── calcsvr │ │ │ ├── Empty.go │ │ │ ├── AddResp.go │ │ │ ├── AuthError.go │ │ │ ├── BindError.go │ │ │ ├── GenericError.go │ │ │ ├── ValidateError.go │ │ │ ├── AddReq.go │ │ │ ├── AddError.go │ │ │ ├── FieldError.go │ │ │ ├── ValidateErrorType.go │ │ │ └── CommonError.go │ │ ├── nested │ │ │ ├── Empty.go │ │ │ ├── Extra.go │ │ │ ├── AuthError.go │ │ │ ├── BindError.go │ │ │ ├── GenericError.go │ │ │ ├── ValidateError.go │ │ │ ├── AddReq.go │ │ │ ├── AddResp.go │ │ │ ├── AddError.go │ │ │ ├── FieldError.go │ │ │ ├── ValidateErrorType.go │ │ │ └── CommonError.go │ │ ├── todolistsvr │ │ │ ├── Empty.go │ │ │ ├── AddReq.go │ │ │ ├── AddResp.go │ │ │ ├── Todo.go │ │ │ ├── ListResp.go │ │ │ ├── AuthError.go │ │ │ ├── BindError.go │ │ │ ├── GenericError.go │ │ │ ├── ValidateError.go │ │ │ ├── AddError.go │ │ │ ├── FieldError.go │ │ │ ├── ValidateErrorType.go │ │ │ └── CommonError.go │ │ └── echosvr │ │ │ └── Msg.go │ ├── ts │ │ ├── .keep │ │ ├── axios │ │ │ └── .keep │ │ ├── fetch │ │ │ └── .keep │ │ └── wechat │ │ │ └── .keep │ ├── package │ │ └── go │ │ │ ├── .keep │ │ │ ├── common │ │ │ ├── Empty.go │ │ │ ├── AuthError.go │ │ │ ├── BindError.go │ │ │ ├── GenericError.go │ │ │ ├── ValidateError.go │ │ │ ├── FieldError.go │ │ │ ├── ValidateErrorType.go │ │ │ └── CommonError.go │ │ │ ├── calcsvrmain │ │ │ ├── Empty.go │ │ │ ├── AddResp.go │ │ │ ├── AuthError.go │ │ │ ├── BindError.go │ │ │ ├── GenericError.go │ │ │ ├── ValidateError.go │ │ │ ├── AddReq.go │ │ │ ├── AddError.go │ │ │ ├── FieldError.go │ │ │ ├── ValidateErrorType.go │ │ │ └── CommonError.go │ │ │ ├── calcsvrmain_without │ │ │ ├── Empty.go │ │ │ ├── AddResp.go │ │ │ ├── AuthError.go │ │ │ ├── BindError.go │ │ │ ├── GenericError.go │ │ │ ├── ValidateError.go │ │ │ ├── AddReq.go │ │ │ ├── AddError.go │ │ │ ├── FieldError.go │ │ │ ├── ValidateErrorType.go │ │ │ └── CommonError.go │ │ │ ├── calc │ │ │ └── AddReq.go │ │ │ ├── calcsvr │ │ │ └── AddReq.go │ │ │ └── github.com │ │ │ └── yoozoo │ │ │ └── protoapi │ │ │ └── calcsvr │ │ │ └── AddReq.go │ ├── app │ │ └── modules │ │ │ └── todolist │ │ │ ├── models │ │ │ ├── ValidateErrorType.php │ │ │ ├── Blank.php │ │ │ ├── Todo.php │ │ │ ├── AddResp.php │ │ │ ├── AddReq.php │ │ │ ├── AuthError.php │ │ │ ├── BindError.php │ │ │ ├── GenericError.php │ │ │ └── ListResp.php │ │ │ ├── handlers │ │ │ ├── RequestHandler.php │ │ │ └── ErrorHandler.php │ │ │ └── RequestHandler.php │ └── com │ │ └── yoozoo │ │ └── spring │ │ ├── Empty.java │ │ ├── EnvListRequest.java │ │ ├── TagListRequest.java │ │ ├── AuthError.java │ │ ├── BindError.java │ │ ├── EnvListResponse.java │ │ ├── KeyListResponse.java │ │ ├── TagListResponse.java │ │ ├── GenericError.java │ │ ├── ProductListRequest.java │ │ ├── ValidateError.java │ │ ├── ProductListResponse.java │ │ ├── KeyValueResponse.java │ │ ├── KeyValueListResponse.java │ │ ├── KVHistoryResponse.java │ │ ├── Env.java │ │ ├── Error.java │ │ ├── Tag.java │ │ ├── KeyListRequest.java │ │ ├── KVHistoryRequest.java │ │ ├── KeyValueListRequest.java │ │ ├── Product.java │ │ ├── FieldError.java │ │ ├── KeyValueRequest.java │ │ ├── SearchKeyValueListRequest.java │ │ ├── UpdateServiceRequest.java │ │ ├── UpdateServiceResponse.java │ │ ├── UploadProtoFileRequest.java │ │ ├── UploadProtoFileResponse.java │ │ ├── ServiceListRequest.java │ │ └── ServiceListResponse.java ├── result │ ├── go │ │ └── .keep │ ├── ts │ │ ├── .keep │ │ ├── axios │ │ │ └── .keep │ │ ├── fetch │ │ │ └── .keep │ │ └── wechat │ │ │ └── .keep │ └── package │ │ └── go │ │ └── .keep ├── proto │ ├── package │ │ ├── nopackage_addReq.proto │ │ ├── package_addReq.proto │ │ ├── gopackage_addReq.proto │ │ ├── mixpackage_addReq.proto │ │ ├── gopackage_addReqFull.proto │ │ ├── gopackage_calc.proto │ │ ├── nopackage_calc.proto │ │ ├── gopackage_calcFull.proto │ │ ├── package_calc._without_commonerror.proto │ │ ├── package_calc.proto │ │ ├── package_calc_commonerror.proto │ │ ├── mixpackage_calc.proto │ │ ├── gopackage_calc_warn.proto │ │ ├── nopackage_calc_warn.proto │ │ └── common.proto │ ├── confusion2.proto │ ├── echo.proto │ ├── confusion.proto │ ├── nested.proto │ ├── calc.proto │ ├── todolist.proto │ ├── common.proto │ └── login.proto ├── test_echo.go ├── example.proto ├── simple.proto └── test_todolist.go ├── vendor ├── github.com │ ├── spf13 │ │ ├── pflag │ │ │ ├── .gitignore │ │ │ └── .travis.yml │ │ └── cobra │ │ │ ├── command_notwin.go │ │ │ ├── .mailmap │ │ │ ├── command_win.go │ │ │ ├── .travis.yml │ │ │ └── .gitignore │ ├── mattn │ │ ├── go-isatty │ │ │ ├── doc.go │ │ │ ├── .travis.yml │ │ │ ├── isatty_others.go │ │ │ ├── isatty_solaris.go │ │ │ ├── isatty_linux.go │ │ │ ├── isatty_appengine.go │ │ │ ├── isatty_bsd.go │ │ │ ├── isatty_linux_ppc64x.go │ │ │ └── LICENSE │ │ └── go-colorable │ │ │ ├── .travis.yml │ │ │ ├── colorable_appengine.go │ │ │ ├── colorable_others.go │ │ │ └── LICENSE │ ├── golang │ │ └── protobuf │ │ │ ├── AUTHORS │ │ │ └── CONTRIBUTORS │ ├── valyala │ │ ├── fasttemplate │ │ │ ├── unsafe_gae.go │ │ │ ├── unsafe.go │ │ │ └── LICENSE │ │ └── bytebufferpool │ │ │ ├── doc.go │ │ │ ├── .travis.yml │ │ │ └── README.md │ └── inconshreveable │ │ └── mousetrap │ │ ├── trap_others.go │ │ ├── LICENSE │ │ └── README.md └── golang.org │ └── x │ ├── sys │ ├── unix │ │ ├── .gitignore │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── constants.go │ │ ├── syscall_linux_amd64_gc.go │ │ ├── aliases.go │ │ ├── pagesize_unix.go │ │ ├── fcntl_linux_32bit.go │ │ ├── asm_solaris_amd64.s │ │ ├── gccgo_linux_amd64.go │ │ ├── syscall_linux_gc.go │ │ ├── race0.go │ │ ├── syscall_solaris_amd64.go │ │ ├── syscall_linux_gc_386.go │ │ ├── syscall_unix_gc.go │ │ ├── dirent.go │ │ ├── syscall_linux_gccgo_arm.go │ │ ├── str.go │ │ ├── race.go │ │ ├── env_unix.go │ │ ├── asm_freebsd_arm.s │ │ ├── asm_netbsd_arm.s │ │ ├── asm_openbsd_arm.s │ │ ├── asm_darwin_386.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_netbsd_386.s │ │ ├── asm_openbsd_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_netbsd_amd64.s │ │ ├── asm_openbsd_amd64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── asm_darwin_arm.s │ │ ├── bluetooth_linux.go │ │ ├── asm_darwin_arm64.s │ │ ├── dev_darwin.go │ │ ├── syscall_netbsd_amd64.go │ │ ├── syscall_netbsd_386.go │ │ ├── syscall_netbsd_arm.go │ │ ├── syscall_openbsd_386.go │ │ ├── syscall_openbsd_arm.go │ │ ├── mksysnum_darwin.pl │ │ ├── dev_netbsd.go │ │ ├── dev_openbsd.go │ │ ├── ioctl.go │ │ ├── syscall_openbsd_amd64.go │ │ ├── syscall_aix_ppc64.go │ │ ├── syscall_aix_ppc.go │ │ ├── fcntl.go │ │ ├── syscall_linux_gccgo_386.go │ │ ├── dev_freebsd.go │ │ └── dev_dragonfly.go │ ├── AUTHORS │ └── CONTRIBUTORS │ └── crypto │ ├── AUTHORS │ └── CONTRIBUTORS ├── .gitattributes ├── docs ├── dev_notes.md └── protoapi_cli.md ├── .gitignore ├── util ├── error.go └── misc.go ├── generator ├── template │ ├── yii2 │ │ ├── models │ │ │ └── enum.gophp │ │ ├── handlers │ │ │ ├── RequestHandler.gophp │ │ │ └── ErrorHandler.gophp │ │ └── RequestHandler.gophp │ ├── echo_enum.gogo │ ├── go │ │ └── enum.gogo │ ├── spring_struct.gojava │ ├── ts │ │ ├── objs.gots │ │ ├── helper.gots │ │ └── helper_fetch.gots │ ├── spring_service.gojava │ └── echo_struct.gogo └── output │ ├── phpyii2 │ └── php.go │ ├── echo_enum.go │ ├── echo_v4.go │ └── spring_service.go ├── ChangeLog.md ├── .travis.yml ├── Jenkinsfile ├── b.bat ├── go.mod ├── Gopkg.toml ├── cmd └── root.go ├── proto └── protoapi_common.proto ├── protoapigo └── json_api_binder.go └── LICENSE /test/expected/go/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/expected/ts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/result/go/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/result/ts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/expected/ts/axios/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/expected/ts/fetch/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/result/package/go/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/result/ts/axios/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/result/ts/fetch/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/result/ts/wechat/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/expected/package/go/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/expected/ts/wechat/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | generator/template/**/* text eol=lf 2 | generator/template/* text eol=lf 3 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_notwin.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package cobra 4 | 5 | var preExecHookFn func(*Command) 6 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/Empty.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // Empty 6 | type Empty struct { 7 | } 8 | -------------------------------------------------------------------------------- /test/expected/go/calcsvr/Empty.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvr 4 | 5 | // Empty 6 | type Empty struct { 7 | } 8 | -------------------------------------------------------------------------------- /test/expected/go/nested/Empty.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package nested 4 | 5 | // Empty 6 | type Empty struct { 7 | } 8 | -------------------------------------------------------------------------------- /docs/dev_notes.md: -------------------------------------------------------------------------------- 1 | * Should refactor generator with proto_structs completely 2 | * Document best practise for adding new gen 3 | * Review test cases 4 | 5 | -------------------------------------------------------------------------------- /test/expected/package/go/common/Empty.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package common 4 | 5 | // Empty 6 | type Empty struct { 7 | } 8 | -------------------------------------------------------------------------------- /test/expected/go/todolistsvr/Empty.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package todolistsvr 4 | 5 | // Empty 6 | type Empty struct { 7 | } 8 | -------------------------------------------------------------------------------- /test/expected/package/go/calcsvrmain/Empty.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvrmain 4 | 5 | // Empty 6 | type Empty struct { 7 | } 8 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/EnvListRequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // EnvListRequest 6 | type EnvListRequest struct { 7 | } 8 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/TagListRequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // TagListRequest 6 | type TagListRequest struct { 7 | } 8 | -------------------------------------------------------------------------------- /test/expected/package/go/calcsvrmain_without/Empty.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvrmain_without 4 | 5 | // Empty 6 | type Empty struct { 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | test/result/ 2 | *.exe 3 | protoapi 4 | .gradle 5 | .idea 6 | build 7 | out 8 | /bin 9 | .classpath 10 | .project 11 | .settings 12 | tmp/ 13 | .vscode/ 14 | *.gob 15 | *.out 16 | -------------------------------------------------------------------------------- /test/proto/package/nopackage_addReq.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | message AddReq { 8 | int32 x = 1; 9 | int32 y = 2; 10 | } 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /util/error.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | // Die prints error and exit 9 | func Die(err error) { 10 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) 11 | os.Exit(1) 12 | } 13 | -------------------------------------------------------------------------------- /util/misc.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | func IsStrInSlice(str string, slice []string) bool { 4 | for _, s := range slice { 5 | if s == str { 6 | return true 7 | } 8 | } 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.mailmap: -------------------------------------------------------------------------------- 1 | Steve Francia 2 | Bjørn Erik Pedersen 3 | Fabiano Franz 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at https://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at https://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /test/expected/app/modules/todolist/models/ValidateErrorType.php: -------------------------------------------------------------------------------- 1 | envs; 12 | 13 | @JsonCreator 14 | public EnvListResponse(@JsonProperty("envs") List envs) { 15 | this.envs = envs; 16 | } 17 | 18 | public List getEnvs() { 19 | return envs; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/KeyListResponse.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class KeyListResponse { 11 | private final List keys; 12 | 13 | @JsonCreator 14 | public KeyListResponse(@JsonProperty("keys") List keys) { 15 | this.keys = keys; 16 | } 17 | 18 | public List getKeys() { 19 | return keys; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/TagListResponse.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class TagListResponse { 11 | private final List tags; 12 | 13 | @JsonCreator 14 | public TagListResponse(@JsonProperty("tags") List tags) { 15 | this.tags = tags; 16 | } 17 | 18 | public List getTags() { 19 | return tags; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package mousetrap 4 | 5 | // StartedByExplorer returns true if the program was invoked by the user 6 | // double-clicking on the executable from explorer.exe 7 | // 8 | // It is conservative and returns false if any of the internal calls fail. 9 | // It does not guarantee that the program was run from a terminal. It only can tell you 10 | // whether it was launched from explorer.exe 11 | // 12 | // On non-Windows platforms, it always returns false. 13 | func StartedByExplorer() bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/GenericError.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class GenericError { 11 | private final String message; 12 | 13 | @JsonCreator 14 | public GenericError(@JsonProperty("message") String message) { 15 | this.message = message; 16 | } 17 | 18 | public String getMessage() { 19 | return message; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/ProductListRequest.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class ProductListRequest { 11 | private final int env_id; 12 | 13 | @JsonCreator 14 | public ProductListRequest(@JsonProperty("env_id") int env_id) { 15 | this.env_id = env_id; 16 | } 17 | 18 | public int getEnv_id() { 19 | return env_id; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/KeyValueListRequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // KeyValueListRequest 6 | type KeyValueListRequest struct { 7 | Service_id int `json:"service_id"` 8 | Keys []*Key `json:"keys"` 9 | } 10 | 11 | func (r *KeyValueListRequest) GetService_id() int { 12 | if r == nil { 13 | var zeroVal int 14 | return zeroVal 15 | } 16 | return r.Service_id 17 | } 18 | 19 | func (r *KeyValueListRequest) GetKeys() []*Key { 20 | if r == nil { 21 | var zeroVal []*Key 22 | return zeroVal 23 | } 24 | return r.Keys 25 | } 26 | -------------------------------------------------------------------------------- /test/proto/package/gopackage_calc.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | import "gopackage_addReq.proto"; 9 | 10 | package calcmain; 11 | option go_package = "calcsvrmain"; 12 | 13 | message AddResp { 14 | int32 result = 1; 15 | } 16 | 17 | message AddError { 18 | AddReq req = 1; 19 | string error = 2; 20 | } 21 | 22 | service CalcService { 23 | option (common.common_error) = "common.CommonError"; 24 | rpc add(AddReq) returns (AddResp) { 25 | option (common.error) = "AddError"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/proto/package/nopackage_calc.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | import "nopackage_addReq.proto"; 9 | 10 | package calcmain; 11 | option go_package = "calcsvrmain"; 12 | 13 | message AddResp { 14 | int32 result = 1; 15 | } 16 | 17 | message AddError { 18 | AddReq req = 1; 19 | string error = 2; 20 | } 21 | 22 | service CalcService { 23 | option (common.common_error) = "common.CommonError"; 24 | rpc add(AddReq) returns (AddResp) { 25 | option (common.error) = "AddError"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/proto/package/gopackage_calcFull.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | import "gopackage_addReqFull.proto"; 9 | 10 | package calcmain; 11 | option go_package = "calcsvrmain"; 12 | 13 | message AddResp { 14 | int32 result = 1; 15 | } 16 | 17 | message AddError { 18 | AddReq req = 1; 19 | string error = 2; 20 | } 21 | 22 | service CalcService { 23 | option (common.common_error) = "common.CommonError"; 24 | rpc add(AddReq) returns (AddResp) { 25 | option (common.error) = "AddError"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/FieldError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // FieldError 6 | type FieldError struct { 7 | FieldName string `json:"fieldName"` 8 | ErrorType ValidateErrorType `json:"errorType"` 9 | } 10 | 11 | func (r *FieldError) GetFieldName() string { 12 | if r == nil { 13 | var zeroVal string 14 | return zeroVal 15 | } 16 | return r.FieldName 17 | } 18 | 19 | func (r *FieldError) GetErrorType() ValidateErrorType { 20 | if r == nil { 21 | var zeroVal ValidateErrorType 22 | return zeroVal 23 | } 24 | return r.ErrorType 25 | } 26 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/KeyValueRequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // KeyValueRequest 6 | type KeyValueRequest struct { 7 | Service_id int `json:"service_id"` 8 | Key_values []*KeyValue `json:"key_values"` 9 | } 10 | 11 | func (r *KeyValueRequest) GetService_id() int { 12 | if r == nil { 13 | var zeroVal int 14 | return zeroVal 15 | } 16 | return r.Service_id 17 | } 18 | 19 | func (r *KeyValueRequest) GetKey_values() []*KeyValue { 20 | if r == nil { 21 | var zeroVal []*KeyValue 22 | return zeroVal 23 | } 24 | return r.Key_values 25 | } 26 | -------------------------------------------------------------------------------- /test/expected/go/calcsvr/FieldError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvr 4 | 5 | // FieldError 6 | type FieldError struct { 7 | FieldName string `json:"fieldName"` 8 | ErrorType ValidateErrorType `json:"errorType"` 9 | } 10 | 11 | func (r *FieldError) GetFieldName() string { 12 | if r == nil { 13 | var zeroVal string 14 | return zeroVal 15 | } 16 | return r.FieldName 17 | } 18 | 19 | func (r *FieldError) GetErrorType() ValidateErrorType { 20 | if r == nil { 21 | var zeroVal ValidateErrorType 22 | return zeroVal 23 | } 24 | return r.ErrorType 25 | } 26 | -------------------------------------------------------------------------------- /test/expected/go/nested/FieldError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package nested 4 | 5 | // FieldError 6 | type FieldError struct { 7 | FieldName string `json:"fieldName"` 8 | ErrorType ValidateErrorType `json:"errorType"` 9 | } 10 | 11 | func (r *FieldError) GetFieldName() string { 12 | if r == nil { 13 | var zeroVal string 14 | return zeroVal 15 | } 16 | return r.FieldName 17 | } 18 | 19 | func (r *FieldError) GetErrorType() ValidateErrorType { 20 | if r == nil { 21 | var zeroVal ValidateErrorType 22 | return zeroVal 23 | } 24 | return r.ErrorType 25 | } 26 | -------------------------------------------------------------------------------- /test/proto/nested.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | 9 | option go_package = "nested"; 10 | 11 | message AddReq { 12 | int32 x = 1; 13 | int32 y = 2; 14 | } 15 | 16 | message AddResp { 17 | message Extra { 18 | string message = 1; 19 | } 20 | int32 result = 1; 21 | Extra extra = 2; 22 | } 23 | 24 | message AddError { 25 | AddReq req = 1; 26 | string error = 2; 27 | } 28 | 29 | service CalcService { 30 | rpc add(AddReq) returns (AddResp) { 31 | option (error) = "AddError"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /generator/output/phpyii2/php.go: -------------------------------------------------------------------------------- 1 | package phpyii2 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/yoozoo/protoapi/generator/data" 7 | ) 8 | 9 | //GetPHPClassName rename class to valid php class name 10 | func getPHPClassName(old string) string { 11 | if strings.ToUpper(old) == "EMPTY" { 12 | return "Blank" 13 | } 14 | switch old { 15 | case data.IntFieldType: 16 | return "int" 17 | case data.BooleanFieldType: 18 | return "boolean" 19 | case data.StringFieldType: 20 | return "string" 21 | case data.DoubleFieldType: 22 | return "double" 23 | default: 24 | return strings.Title(old) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/expected/package/go/common/FieldError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package common 4 | 5 | // FieldError 6 | type FieldError struct { 7 | FieldName string `json:"fieldName"` 8 | ErrorType ValidateErrorType `json:"errorType"` 9 | } 10 | 11 | func (r *FieldError) GetFieldName() string { 12 | if r == nil { 13 | var zeroVal string 14 | return zeroVal 15 | } 16 | return r.FieldName 17 | } 18 | 19 | func (r *FieldError) GetErrorType() ValidateErrorType { 20 | if r == nil { 21 | var zeroVal ValidateErrorType 22 | return zeroVal 23 | } 24 | return r.ErrorType 25 | } 26 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/ValidateError.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class ValidateError { 11 | private final List errors; 12 | 13 | @JsonCreator 14 | public ValidateError(@JsonProperty("errors") List errors) { 15 | this.errors = errors; 16 | } 17 | 18 | public List getErrors() { 19 | return errors; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/expected/go/todolistsvr/FieldError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package todolistsvr 4 | 5 | // FieldError 6 | type FieldError struct { 7 | FieldName string `json:"fieldName"` 8 | ErrorType ValidateErrorType `json:"errorType"` 9 | } 10 | 11 | func (r *FieldError) GetFieldName() string { 12 | if r == nil { 13 | var zeroVal string 14 | return zeroVal 15 | } 16 | return r.FieldName 17 | } 18 | 19 | func (r *FieldError) GetErrorType() ValidateErrorType { 20 | if r == nil { 21 | var zeroVal ValidateErrorType 22 | return zeroVal 23 | } 24 | return r.ErrorType 25 | } 26 | -------------------------------------------------------------------------------- /test/expected/package/go/calcsvrmain/FieldError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvrmain 4 | 5 | // FieldError 6 | type FieldError struct { 7 | FieldName string `json:"fieldName"` 8 | ErrorType ValidateErrorType `json:"errorType"` 9 | } 10 | 11 | func (r *FieldError) GetFieldName() string { 12 | if r == nil { 13 | var zeroVal string 14 | return zeroVal 15 | } 16 | return r.FieldName 17 | } 18 | 19 | func (r *FieldError) GetErrorType() ValidateErrorType { 20 | if r == nil { 21 | var zeroVal ValidateErrorType 22 | return zeroVal 23 | } 24 | return r.ErrorType 25 | } 26 | -------------------------------------------------------------------------------- /test/expected/package/go/calcsvrmain_without/FieldError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvrmain_without 4 | 5 | // FieldError 6 | type FieldError struct { 7 | FieldName string `json:"fieldName"` 8 | ErrorType ValidateErrorType `json:"errorType"` 9 | } 10 | 11 | func (r *FieldError) GetFieldName() string { 12 | if r == nil { 13 | var zeroVal string 14 | return zeroVal 15 | } 16 | return r.FieldName 17 | } 18 | 19 | func (r *FieldError) GetErrorType() ValidateErrorType { 20 | if r == nil { 21 | var zeroVal ValidateErrorType 22 | return zeroVal 23 | } 24 | return r.ErrorType 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Alan Shreve 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/ProductListResponse.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class ProductListResponse { 11 | private final List products; 12 | 13 | @JsonCreator 14 | public ProductListResponse(@JsonProperty("products") List products) { 15 | this.products = products; 16 | } 17 | 18 | public List getProducts() { 19 | return products; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | matrix: 4 | include: 5 | - go: 1.9.4 6 | - go: 1.10.0 7 | - go: tip 8 | allow_failures: 9 | - go: tip 10 | 11 | before_install: 12 | - mkdir -p bin 13 | - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.3/shellcheck 14 | - chmod +x bin/shellcheck 15 | script: 16 | - PATH=$PATH:$PWD/bin go test -v ./... 17 | - go build 18 | - diff -u <(echo -n) <(gofmt -d -s .) 19 | - if [ -z $NOVET ]; then 20 | diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); 21 | fi 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/KeyValueResponse.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class KeyValueResponse { 11 | private final List key_values; 12 | 13 | @JsonCreator 14 | public KeyValueResponse(@JsonProperty("key_values") List key_values) { 15 | this.key_values = key_values; 16 | } 17 | 18 | public List getKey_values() { 19 | return key_values; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | -------------------------------------------------------------------------------- /generator/template/echo_enum.gogo: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package {{.Package}} 4 | 5 | type {{.Name}} int 6 | 7 | const ( 8 | {{- range .Fields }} 9 | {{.Name}} {{$.Name}} = {{.Value}} 10 | {{- end}} 11 | ) 12 | 13 | func (code {{.Name}}) String() string { 14 | names := map[{{.Name}}]string{ 15 | {{- range .Fields }} 16 | {{.Name}}: "{{.Name}}", 17 | {{- end}} 18 | } 19 | 20 | return names[code] 21 | } 22 | 23 | func (code {{.Name}}) Code() int { 24 | return (int)(code) 25 | } 26 | {{- range .Fields }} 27 | 28 | func (code {{$.Name}}) Is{{.Name}}() bool { 29 | return code == {{.Name}} 30 | } 31 | {{- end }} 32 | -------------------------------------------------------------------------------- /generator/template/go/enum.gogo: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package {{.Package}} 4 | 5 | type {{.Name}} int 6 | 7 | const ( 8 | {{- range .Fields }} 9 | {{.Name}} {{$.Name}} = {{.Value}} 10 | {{- end}} 11 | ) 12 | 13 | func (code {{.Name}}) String() string { 14 | names := map[{{.Name}}]string{ 15 | {{- range .Fields }} 16 | {{.Name}}: "{{.Name}}", 17 | {{- end}} 18 | } 19 | 20 | return names[code] 21 | } 22 | 23 | func (code {{.Name}}) Code() int { 24 | return (int)(code) 25 | } 26 | {{- range .Fields }} 27 | 28 | func (code {{$.Name}}) Is{{.Name}}() bool { 29 | return code == {{.Name}} 30 | } 31 | {{- end }} 32 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | # Vim files https://github.com/github/gitignore/blob/master/Global/Vim.gitignore 23 | # swap 24 | [._]*.s[a-w][a-z] 25 | [._]s[a-w][a-z] 26 | # session 27 | Session.vim 28 | # temporary 29 | .netrwhist 30 | *~ 31 | # auto-generated tag files 32 | tags 33 | 34 | *.exe 35 | 36 | cobra.test 37 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/KeyValueListResponse.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class KeyValueListResponse { 11 | private final List key_values; 12 | 13 | @JsonCreator 14 | public KeyValueListResponse(@JsonProperty("key_values") List key_values) { 15 | this.key_values = key_values; 16 | } 17 | 18 | public List getKey_values() { 19 | return key_values; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/KVHistoryResponse.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class KVHistoryResponse { 11 | private final List KVhistorys; 12 | 13 | @JsonCreator 14 | public KVHistoryResponse(@JsonProperty("KVhistorys") List KVhistorys) { 15 | this.KVhistorys = KVhistorys; 16 | } 17 | 18 | public List getKVhistorys() { 19 | return KVhistorys; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/proto/calc.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | 9 | option go_package = "calcsvr"; 10 | 11 | message AddReq { 12 | int32 x = 1; 13 | int32 y = 2; 14 | } 15 | 16 | message AddResp { 17 | int32 result = 1; 18 | } 19 | 20 | message AddError { 21 | AddReq req = 1; 22 | string error = 2; 23 | } 24 | 25 | service CalcService { 26 | option (auth) = true; 27 | rpc add(AddReq) returns (AddResp) { 28 | option (error) = "AddError"; 29 | } 30 | } 31 | 32 | service ExtendCalcService { 33 | rpc minus(AddReq) returns (AddResp) { 34 | option (error) = "AddError"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo,386 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | 15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,gccgo,arm 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | -------------------------------------------------------------------------------- /test/proto/todolist.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | 9 | package todolist; 10 | 11 | option go_package = "todolistsvr"; 12 | 13 | message Todo { string title = 1; } 14 | 15 | message AddReq { Todo item = 1; } 16 | 17 | message AddResp { int32 count = 1; } 18 | 19 | message listResp { repeated Todo items = 1; } 20 | 21 | message AddError { 22 | AddReq req = 1; 23 | string error = 2; 24 | } 25 | 26 | service TodolistService { 27 | option (common_error) = "CommonError"; 28 | 29 | rpc add(AddReq) returns (AddResp) { 30 | option (error) = "AddError"; 31 | } 32 | 33 | rpc list(Empty) returns (listResp) {} 34 | } 35 | -------------------------------------------------------------------------------- /generator/template/spring_struct.gojava: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package {{.Package}}; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class {{.ClassName}} { 11 | {{- range .Fields}} 12 | private final {{.JavaType}} {{ .Name }}; 13 | {{- end }} 14 | 15 | @JsonCreator 16 | public {{.ClassName}}({{.ContructParam}}) { 17 | {{- range .Fields}} 18 | this.{{ .Name }} = {{ .Name }}; 19 | {{- end }} 20 | } 21 | 22 | {{range .Fields -}} 23 | public {{.JavaType}} get{{ .Title }}() { 24 | return {{ .Name }}; 25 | } 26 | {{ end }} 27 | } 28 | -------------------------------------------------------------------------------- /docs/protoapi_cli.md: -------------------------------------------------------------------------------- 1 | # protoapi CLI 2 | 3 | protoapi command line tool 4 | 5 | ## First time use 6 | 7 | Please run init command to initialize 8 | 9 | ```bash 10 | protoapi init 11 | ``` 12 | 13 | ## Support commands 14 | 15 | * root 16 | * init 17 | * gen 18 | * help 19 | 20 | ## root command 21 | 22 | root command will display help information. 23 | 24 | ## init command 25 | 26 | init command will download protoc and other required files into your home directory. 27 | 28 | ## gen command 29 | 30 | gen command will generate user declared language/framework code including API interface and request/response. 31 | 32 | To run gen command, use: 33 | 34 | ```bash 35 | protoapi gen --lang=[language] [output directory] [proto file] 36 | ``` 37 | -------------------------------------------------------------------------------- /test/proto/package/package_calc._without_commonerror.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | import "package_addReq.proto"; 9 | 10 | package calcmain; 11 | option go_package = "calcsvrmain_without"; 12 | 13 | message AddReq { 14 | int32 x = 1; 15 | int32 y = 2; 16 | } 17 | 18 | message AddResp { 19 | int32 result = 1; 20 | } 21 | 22 | message AddError { 23 | AddReq req = 1; 24 | string error = 2; 25 | } 26 | 27 | service CalcService { 28 | rpc add(AddReq) returns (AddResp) { 29 | option (common.error) = "AddError"; 30 | } 31 | 32 | rpc add2(calc.AddReq) returns (AddResp) { 33 | option (common.error) = "AddError"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /generator/output/echo_enum.go: -------------------------------------------------------------------------------- 1 | package output 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/yoozoo/protoapi/generator/data" 7 | ) 8 | 9 | type echoEnumField struct { 10 | data.EnumField 11 | } 12 | 13 | func newEchoEnum(enum *data.EnumData, packageName string) *echoEnum { 14 | ss := strings.Split(packageName, "/") 15 | s := ss[len(ss)-1] 16 | o := &echoEnum{ 17 | enum, 18 | s, 19 | nil, 20 | } 21 | o.init() 22 | return o 23 | } 24 | 25 | type echoEnum struct { 26 | *data.EnumData 27 | Package string 28 | Fields []*echoEnumField 29 | } 30 | 31 | func (s *echoEnum) init() { 32 | s.Fields = make([]*echoEnumField, len(s.EnumData.Fields)) 33 | for i, f := range s.EnumData.Fields { 34 | s.Fields[i] = &echoEnumField{f} 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/Env.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class Env { 11 | private final int env_id; 12 | private final String env_name; 13 | 14 | @JsonCreator 15 | public Env(@JsonProperty("env_id") int env_id, @JsonProperty("env_name") String env_name) { 16 | this.env_id = env_id; 17 | this.env_name = env_name; 18 | } 19 | 20 | public int getEnv_id() { 21 | return env_id; 22 | } 23 | public String getEnv_name() { 24 | return env_name; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/Error.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class Error { 11 | private final ErrorCode code; 12 | private final String message; 13 | 14 | @JsonCreator 15 | public Error(@JsonProperty("code") ErrorCode code, @JsonProperty("message") String message) { 16 | this.code = code; 17 | this.message = message; 18 | } 19 | 20 | public ErrorCode getCode() { 21 | return code; 22 | } 23 | public String getMessage() { 24 | return message; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/Tag.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class Tag { 11 | private final int tag_id; 12 | private final String tag_name; 13 | 14 | @JsonCreator 15 | public Tag(@JsonProperty("tag_id") int tag_id, @JsonProperty("tag_name") String tag_name) { 16 | this.tag_id = tag_id; 17 | this.tag_name = tag_name; 18 | } 19 | 20 | public int getTag_id() { 21 | return tag_id; 22 | } 23 | public String getTag_name() { 24 | return tag_name; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /test/proto/package/package_calc.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | import "package_addReq.proto"; 9 | 10 | package calcmain; 11 | option go_package = "calcsvrmain"; 12 | 13 | message AddReq { 14 | int32 x = 1; 15 | int32 y = 2; 16 | } 17 | 18 | message AddResp { 19 | int32 result = 1; 20 | } 21 | 22 | message AddError { 23 | AddReq req = 1; 24 | string error = 2; 25 | } 26 | 27 | service CalcService { 28 | option (common.common_error) = "common.CommonError"; 29 | rpc add(AddReq) returns (AddResp) { 30 | option (common.error) = "AddError"; 31 | } 32 | 33 | rpc add2(calc.AddReq) returns (AddResp) { 34 | option (common.error) = "AddError"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/ValidateErrorType.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | type ValidateErrorType int 6 | 7 | const ( 8 | INVALID_EMAIL ValidateErrorType = 0 9 | FIELD_REQUIRED ValidateErrorType = 1 10 | ) 11 | 12 | func (code ValidateErrorType) String() string { 13 | names := map[ValidateErrorType]string{ 14 | INVALID_EMAIL: "INVALID_EMAIL", 15 | FIELD_REQUIRED: "FIELD_REQUIRED", 16 | } 17 | 18 | return names[code] 19 | } 20 | 21 | func (code ValidateErrorType) Code() int { 22 | return (int)(code) 23 | } 24 | 25 | func (code ValidateErrorType) IsINVALID_EMAIL() bool { 26 | return code == INVALID_EMAIL 27 | } 28 | 29 | func (code ValidateErrorType) IsFIELD_REQUIRED() bool { 30 | return code == FIELD_REQUIRED 31 | } 32 | -------------------------------------------------------------------------------- /test/expected/go/nested/ValidateErrorType.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package nested 4 | 5 | type ValidateErrorType int 6 | 7 | const ( 8 | INVALID_EMAIL ValidateErrorType = 0 9 | FIELD_REQUIRED ValidateErrorType = 1 10 | ) 11 | 12 | func (code ValidateErrorType) String() string { 13 | names := map[ValidateErrorType]string{ 14 | INVALID_EMAIL: "INVALID_EMAIL", 15 | FIELD_REQUIRED: "FIELD_REQUIRED", 16 | } 17 | 18 | return names[code] 19 | } 20 | 21 | func (code ValidateErrorType) Code() int { 22 | return (int)(code) 23 | } 24 | 25 | func (code ValidateErrorType) IsINVALID_EMAIL() bool { 26 | return code == INVALID_EMAIL 27 | } 28 | 29 | func (code ValidateErrorType) IsFIELD_REQUIRED() bool { 30 | return code == FIELD_REQUIRED 31 | } 32 | -------------------------------------------------------------------------------- /test/proto/package/package_calc_commonerror.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | import "package_addReq.proto"; 9 | 10 | package calcmain; 11 | option go_package = "calcsvrmain"; 12 | 13 | message AddReq { 14 | int32 x = 1; 15 | int32 y = 2; 16 | } 17 | 18 | message AddResp { 19 | int32 result = 1; 20 | } 21 | 22 | message AddError { 23 | AddReq req = 1; 24 | string error = 2; 25 | } 26 | 27 | service CalcService { 28 | option (common.common_error) = "CommonError"; 29 | rpc add(AddReq) returns (AddResp) { 30 | option (common.error) = "AddError"; 31 | } 32 | 33 | rpc add2(calc.AddReq) returns (AddResp) { 34 | option (common.error) = "AddError"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/expected/go/calcsvr/ValidateErrorType.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvr 4 | 5 | type ValidateErrorType int 6 | 7 | const ( 8 | INVALID_EMAIL ValidateErrorType = 0 9 | FIELD_REQUIRED ValidateErrorType = 1 10 | ) 11 | 12 | func (code ValidateErrorType) String() string { 13 | names := map[ValidateErrorType]string{ 14 | INVALID_EMAIL: "INVALID_EMAIL", 15 | FIELD_REQUIRED: "FIELD_REQUIRED", 16 | } 17 | 18 | return names[code] 19 | } 20 | 21 | func (code ValidateErrorType) Code() int { 22 | return (int)(code) 23 | } 24 | 25 | func (code ValidateErrorType) IsINVALID_EMAIL() bool { 26 | return code == INVALID_EMAIL 27 | } 28 | 29 | func (code ValidateErrorType) IsFIELD_REQUIRED() bool { 30 | return code == FIELD_REQUIRED 31 | } 32 | -------------------------------------------------------------------------------- /test/proto/package/mixpackage_calc.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | import "mixpackage_addReq.proto"; 9 | 10 | package calcmain; 11 | option go_package = "calcsvrmain"; 12 | 13 | message AddReq { 14 | int32 x = 1; 15 | int32 y = 2; 16 | } 17 | 18 | message AddResp { 19 | int32 result = 1; 20 | } 21 | 22 | message AddError { 23 | AddReq req = 1; 24 | string error = 2; 25 | } 26 | 27 | service CalcService { 28 | option (common.common_error) = "common.CommonError"; 29 | rpc add(AddReq) returns (AddResp) { 30 | option (common.error) = "AddError"; 31 | } 32 | 33 | rpc add2(calc.AddReq) returns (AddResp) { 34 | option (common.error) = "AddError"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/KeyListRequest.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class KeyListRequest { 11 | private final int service_id; 12 | private final int env_id; 13 | 14 | @JsonCreator 15 | public KeyListRequest(@JsonProperty("service_id") int service_id, @JsonProperty("env_id") int env_id) { 16 | this.service_id = service_id; 17 | this.env_id = env_id; 18 | } 19 | 20 | public int getService_id() { 21 | return service_id; 22 | } 23 | public int getEnv_id() { 24 | return env_id; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test/expected/go/todolistsvr/ValidateErrorType.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package todolistsvr 4 | 5 | type ValidateErrorType int 6 | 7 | const ( 8 | INVALID_EMAIL ValidateErrorType = 0 9 | FIELD_REQUIRED ValidateErrorType = 1 10 | ) 11 | 12 | func (code ValidateErrorType) String() string { 13 | names := map[ValidateErrorType]string{ 14 | INVALID_EMAIL: "INVALID_EMAIL", 15 | FIELD_REQUIRED: "FIELD_REQUIRED", 16 | } 17 | 18 | return names[code] 19 | } 20 | 21 | func (code ValidateErrorType) Code() int { 22 | return (int)(code) 23 | } 24 | 25 | func (code ValidateErrorType) IsINVALID_EMAIL() bool { 26 | return code == INVALID_EMAIL 27 | } 28 | 29 | func (code ValidateErrorType) IsFIELD_REQUIRED() bool { 30 | return code == FIELD_REQUIRED 31 | } 32 | -------------------------------------------------------------------------------- /test/expected/package/go/common/ValidateErrorType.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package common 4 | 5 | type ValidateErrorType int 6 | 7 | const ( 8 | INVALID_EMAIL ValidateErrorType = 0 9 | FIELD_REQUIRED ValidateErrorType = 1 10 | ) 11 | 12 | func (code ValidateErrorType) String() string { 13 | names := map[ValidateErrorType]string{ 14 | INVALID_EMAIL: "INVALID_EMAIL", 15 | FIELD_REQUIRED: "FIELD_REQUIRED", 16 | } 17 | 18 | return names[code] 19 | } 20 | 21 | func (code ValidateErrorType) Code() int { 22 | return (int)(code) 23 | } 24 | 25 | func (code ValidateErrorType) IsINVALID_EMAIL() bool { 26 | return code == INVALID_EMAIL 27 | } 28 | 29 | func (code ValidateErrorType) IsFIELD_REQUIRED() bool { 30 | return code == FIELD_REQUIRED 31 | } 32 | -------------------------------------------------------------------------------- /test/proto/package/gopackage_calc_warn.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | import "gopackage_addReq.proto"; 9 | 10 | package calcmain; 11 | option go_package = "calcsvrmain"; 12 | 13 | message AddReq { 14 | int32 x = 1; 15 | int32 y = 2; 16 | } 17 | 18 | message AddResp { 19 | int32 result = 1; 20 | } 21 | 22 | message AddError { 23 | AddReq req = 1; 24 | string error = 2; 25 | } 26 | 27 | service CalcService { 28 | option (common.common_error) = "common.CommonError"; 29 | rpc add(AddReq) returns (AddResp) { 30 | option (common.error) = "AddError"; 31 | } 32 | 33 | rpc add2(calcmain.AddReq) returns (AddResp) { 34 | option (common.error) = "AddError"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/proto/package/nopackage_calc_warn.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | import "nopackage_addReq.proto"; 9 | 10 | package calcmain; 11 | option go_package = "calcsvrmain"; 12 | 13 | message AddReq { 14 | int32 x = 1; 15 | int32 y = 2; 16 | } 17 | 18 | message AddResp { 19 | int32 result = 1; 20 | } 21 | 22 | message AddError { 23 | AddReq req = 1; 24 | string error = 2; 25 | } 26 | 27 | service CalcService { 28 | option (common.common_error) = "common.CommonError"; 29 | rpc add(AddReq) returns (AddResp) { 30 | option (common.error) = "AddError"; 31 | } 32 | 33 | rpc add2(calcmain.AddReq) returns (AddResp) { 34 | option (common.error) = "AddError"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/KVHistoryRequest.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class KVHistoryRequest { 11 | private final int service_id; 12 | private final int key_id; 13 | 14 | @JsonCreator 15 | public KVHistoryRequest(@JsonProperty("service_id") int service_id, @JsonProperty("key_id") int key_id) { 16 | this.service_id = service_id; 17 | this.key_id = key_id; 18 | } 19 | 20 | public int getService_id() { 21 | return service_id; 22 | } 23 | public int getKey_id() { 24 | return key_id; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/UpdateServiceRequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // UpdateServiceRequest 6 | type UpdateServiceRequest struct { 7 | Service_id int `json:"service_id"` 8 | Tags []*Tag `json:"tags"` 9 | Desc string `json:"desc"` 10 | } 11 | 12 | func (r *UpdateServiceRequest) GetService_id() int { 13 | if r == nil { 14 | var zeroVal int 15 | return zeroVal 16 | } 17 | return r.Service_id 18 | } 19 | 20 | func (r *UpdateServiceRequest) GetTags() []*Tag { 21 | if r == nil { 22 | var zeroVal []*Tag 23 | return zeroVal 24 | } 25 | return r.Tags 26 | } 27 | 28 | func (r *UpdateServiceRequest) GetDesc() string { 29 | if r == nil { 30 | var zeroVal string 31 | return zeroVal 32 | } 33 | return r.Desc 34 | } 35 | -------------------------------------------------------------------------------- /test/expected/package/go/calcsvrmain/ValidateErrorType.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvrmain 4 | 5 | type ValidateErrorType int 6 | 7 | const ( 8 | INVALID_EMAIL ValidateErrorType = 0 9 | FIELD_REQUIRED ValidateErrorType = 1 10 | ) 11 | 12 | func (code ValidateErrorType) String() string { 13 | names := map[ValidateErrorType]string{ 14 | INVALID_EMAIL: "INVALID_EMAIL", 15 | FIELD_REQUIRED: "FIELD_REQUIRED", 16 | } 17 | 18 | return names[code] 19 | } 20 | 21 | func (code ValidateErrorType) Code() int { 22 | return (int)(code) 23 | } 24 | 25 | func (code ValidateErrorType) IsINVALID_EMAIL() bool { 26 | return code == INVALID_EMAIL 27 | } 28 | 29 | func (code ValidateErrorType) IsFIELD_REQUIRED() bool { 30 | return code == FIELD_REQUIRED 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | _ "github.com/mattn/go-isatty" 10 | ) 11 | 12 | // NewColorable return new instance of Writer which handle escape sequence. 13 | func NewColorable(file *os.File) io.Writer { 14 | if file == nil { 15 | panic("nil passed instead of *os.File to NewColorable()") 16 | } 17 | 18 | return file 19 | } 20 | 21 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 22 | func NewColorableStdout() io.Writer { 23 | return os.Stdout 24 | } 25 | 26 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 27 | func NewColorableStderr() io.Writer { 28 | return os.Stderr 29 | } 30 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/UpdateServiceResponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // UpdateServiceResponse 6 | type UpdateServiceResponse struct { 7 | Service_id int `json:"service_id"` 8 | Tags []*Tag `json:"tags"` 9 | Desc string `json:"desc"` 10 | } 11 | 12 | func (r *UpdateServiceResponse) GetService_id() int { 13 | if r == nil { 14 | var zeroVal int 15 | return zeroVal 16 | } 17 | return r.Service_id 18 | } 19 | 20 | func (r *UpdateServiceResponse) GetTags() []*Tag { 21 | if r == nil { 22 | var zeroVal []*Tag 23 | return zeroVal 24 | } 25 | return r.Tags 26 | } 27 | 28 | func (r *UpdateServiceResponse) GetDesc() string { 29 | if r == nil { 30 | var zeroVal string 31 | return zeroVal 32 | } 33 | return r.Desc 34 | } 35 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/KeyValueListRequest.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class KeyValueListRequest { 11 | private final int service_id; 12 | private final List keys; 13 | 14 | @JsonCreator 15 | public KeyValueListRequest(@JsonProperty("service_id") int service_id, @JsonProperty("keys") List keys) { 16 | this.service_id = service_id; 17 | this.keys = keys; 18 | } 19 | 20 | public int getService_id() { 21 | return service_id; 22 | } 23 | public List getKeys() { 24 | return keys; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/UploadProtoFileRequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // UploadProtoFileRequest 6 | type UploadProtoFileRequest struct { 7 | Service_id int `json:"service_id"` 8 | Env_id int `json:"env_id"` 9 | File string `json:"file"` 10 | } 11 | 12 | func (r *UploadProtoFileRequest) GetService_id() int { 13 | if r == nil { 14 | var zeroVal int 15 | return zeroVal 16 | } 17 | return r.Service_id 18 | } 19 | 20 | func (r *UploadProtoFileRequest) GetEnv_id() int { 21 | if r == nil { 22 | var zeroVal int 23 | return zeroVal 24 | } 25 | return r.Env_id 26 | } 27 | 28 | func (r *UploadProtoFileRequest) GetFile() string { 29 | if r == nil { 30 | var zeroVal string 31 | return zeroVal 32 | } 33 | return r.File 34 | } 35 | -------------------------------------------------------------------------------- /test/expected/package/go/calcsvrmain_without/ValidateErrorType.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvrmain_without 4 | 5 | type ValidateErrorType int 6 | 7 | const ( 8 | INVALID_EMAIL ValidateErrorType = 0 9 | FIELD_REQUIRED ValidateErrorType = 1 10 | ) 11 | 12 | func (code ValidateErrorType) String() string { 13 | names := map[ValidateErrorType]string{ 14 | INVALID_EMAIL: "INVALID_EMAIL", 15 | FIELD_REQUIRED: "FIELD_REQUIRED", 16 | } 17 | 18 | return names[code] 19 | } 20 | 21 | func (code ValidateErrorType) Code() int { 22 | return (int)(code) 23 | } 24 | 25 | func (code ValidateErrorType) IsINVALID_EMAIL() bool { 26 | return code == INVALID_EMAIL 27 | } 28 | 29 | func (code ValidateErrorType) IsFIELD_REQUIRED() bool { 30 | return code == FIELD_REQUIRED 31 | } 32 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/UploadProtoFileResponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // UploadProtoFileResponse 6 | type UploadProtoFileResponse struct { 7 | Service_id int `json:"service_id"` 8 | Env_id int `json:"env_id"` 9 | Key_count int `json:"key_count"` 10 | } 11 | 12 | func (r *UploadProtoFileResponse) GetService_id() int { 13 | if r == nil { 14 | var zeroVal int 15 | return zeroVal 16 | } 17 | return r.Service_id 18 | } 19 | 20 | func (r *UploadProtoFileResponse) GetEnv_id() int { 21 | if r == nil { 22 | var zeroVal int 23 | return zeroVal 24 | } 25 | return r.Env_id 26 | } 27 | 28 | func (r *UploadProtoFileResponse) GetKey_count() int { 29 | if r == nil { 30 | var zeroVal int 31 | return zeroVal 32 | } 33 | return r.Key_count 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable return new instance of Writer which handle escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/SearchKeyValueListRequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // SearchKeyValueListRequest 6 | type SearchKeyValueListRequest struct { 7 | Key string `json:"key"` 8 | Service_id int `json:"service_id"` 9 | Env_id int `json:"env_id"` 10 | } 11 | 12 | func (r *SearchKeyValueListRequest) GetKey() string { 13 | if r == nil { 14 | var zeroVal string 15 | return zeroVal 16 | } 17 | return r.Key 18 | } 19 | 20 | func (r *SearchKeyValueListRequest) GetService_id() int { 21 | if r == nil { 22 | var zeroVal int 23 | return zeroVal 24 | } 25 | return r.Service_id 26 | } 27 | 28 | func (r *SearchKeyValueListRequest) GetEnv_id() int { 29 | if r == nil { 30 | var zeroVal int 31 | return zeroVal 32 | } 33 | return r.Env_id 34 | } 35 | -------------------------------------------------------------------------------- /generator/template/ts/objs.gots: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is generated by 'protoapi' 3 | * This file contains all the data structure being used in the generated ts services 4 | * ----------------------------------------------------- 5 | * 该文件生成于protoapi 6 | * 文件包含API前端调用所引用的数据结构定义 7 | */ 8 | 9 | // enums 10 | {{- range .Enums }} 11 | export enum {{.Name}} { 12 | {{- range .Fields }} 13 | {{.Name}} = {{.Value}}, 14 | {{- end }} 15 | } 16 | {{end -}} 17 | // data types 18 | {{- range .DataTypes }} 19 | {{- $errorName := (getCommonErrorName .Name)}} 20 | export interface {{.Name}} { 21 | {{ if (isCommonError .Name) }} 22 | kind: {{$errorName}} 23 | {{end}} 24 | {{- range .Fields }} 25 | {{.Name}}: {{ tsType .DataType}}{{if eq .Label "LABEL_REPEATED"}}[]{{end}} 26 | {{- end }} 27 | } 28 | {{end -}} 29 | 30 | -------------------------------------------------------------------------------- /test/example.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "protoapi_common.proto"; 8 | 9 | // package 10 | package example.ts; 11 | option java_package = "example.spring"; 12 | 13 | message HelloRequest { 14 | string hello = 1; 15 | } 16 | 17 | message HelloResponse { 18 | string hi = 1; 19 | } 20 | 21 | enum ErrorCode { 22 | DefaultError = 0; 23 | GeneralError = 1000; 24 | DatabaseError = 1001; 25 | EtcdError = 1002; 26 | SystemError = 1003; 27 | } 28 | 29 | message Error { 30 | ErrorCode code = 1; 31 | string message = 2; 32 | } 33 | 34 | service HelloService { 35 | rpc sayHello (HelloRequest) returns (HelloResponse) { 36 | option (error) = "Error"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/Product.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class Product { 11 | private final String product_id; 12 | private final String product_name; 13 | 14 | @JsonCreator 15 | public Product(@JsonProperty("product_id") String product_id, @JsonProperty("product_name") String product_name) { 16 | this.product_id = product_id; 17 | this.product_name = product_name; 18 | } 19 | 20 | public String getProduct_id() { 21 | return product_id; 22 | } 23 | public String getProduct_name() { 24 | return product_name; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/FieldError.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class FieldError { 11 | private final String fieldName; 12 | private final ValidateErrorType errorType; 13 | 14 | @JsonCreator 15 | public FieldError(@JsonProperty("fieldName") String fieldName, @JsonProperty("errorType") ValidateErrorType errorType) { 16 | this.fieldName = fieldName; 17 | this.errorType = errorType; 18 | } 19 | 20 | public String getFieldName() { 21 | return fieldName; 22 | } 23 | public ValidateErrorType getErrorType() { 24 | return errorType; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/KeyValueRequest.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class KeyValueRequest { 11 | private final int service_id; 12 | private final List key_values; 13 | 14 | @JsonCreator 15 | public KeyValueRequest(@JsonProperty("service_id") int service_id, @JsonProperty("key_values") List key_values) { 16 | this.service_id = service_id; 17 | this.key_values = key_values; 18 | } 19 | 20 | public int getService_id() { 21 | return service_id; 22 | } 23 | public List getKey_values() { 24 | return key_values; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/yoozoo/protoapi 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/golang/protobuf v1.2.0 7 | github.com/inconshreveable/mousetrap v1.0.0 // indirect 8 | github.com/labstack/echo v3.3.10+incompatible 9 | github.com/labstack/gommon v0.2.8 // indirect 10 | github.com/mattn/go-colorable v0.0.9 // indirect 11 | github.com/mattn/go-isatty v0.0.4 // indirect 12 | github.com/sergi/go-diff v1.0.0 13 | github.com/spf13/cobra v0.0.3 14 | github.com/spf13/pflag v1.0.2 15 | github.com/stretchr/testify v1.3.0 // indirect 16 | github.com/valyala/bytebufferpool v1.0.0 // indirect 17 | github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 // indirect 18 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 // indirect 19 | golang.org/x/sync v0.0.0-20190412183630-56d357773e84 // indirect 20 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 // indirect 21 | ) 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | ignored = ["github.com/labstack/echo"] 28 | 29 | [[constraint]] 30 | name = "github.com/golang/protobuf" 31 | version = "1.2.0" 32 | 33 | [prune] 34 | go-tests = true 35 | unused-packages = true 36 | -------------------------------------------------------------------------------- /generator/template/ts/helper.gots: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * 4 | * @param {response} response the error response 5 | */ 6 | export function errorHandling(err): Promise { 7 | if(!err || err.response === undefined) { 8 | return Promise.reject(err); 9 | } 10 | let data; 11 | try { 12 | data = JSON.parse(err.response.data); 13 | } catch (e) { 14 | data = err.response.data; 15 | } 16 | switch (err.response.status) { 17 | case httpCode.BIZ_ERROR: 18 | return Promise.reject({...err, message: data.message}); 19 | {{if .Gen.HasCommonError}} 20 | case httpCode.COMMON_ERROR: 21 | let returnErr = mapCommonErrorType(data); 22 | if(!returnErr){ 23 | throw err 24 | } 25 | return Promise.reject({...err.response, ...returnErr}); 26 | default: 27 | return Promise.reject(err); 28 | {{end}} 29 | } 30 | } -------------------------------------------------------------------------------- /test/expected/app/modules/todolist/models/Todo.php: -------------------------------------------------------------------------------- 1 | set_title ( $response["title"] ); 14 | } 15 | } 16 | 17 | public function validate() 18 | { 19 | if (!isset($this->title)) { 20 | throw new ProtoApi\GeneralException("'title' is not exist"); 21 | } 22 | } 23 | 24 | public function set_title(string $title) 25 | { 26 | $this->title = $title; 27 | } 28 | 29 | public function get_title() 30 | { 31 | return $this->title; 32 | } 33 | 34 | public function to_array() 35 | { 36 | return array( 37 | "title" => $this->title, 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/ServiceListRequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // ServiceListRequest 6 | type ServiceListRequest struct { 7 | Tag_ids []int `json:"tag_ids"` 8 | Env_id int `json:"env_id"` 9 | Offset int `json:"offset"` 10 | Limit int `json:"limit"` 11 | } 12 | 13 | func (r *ServiceListRequest) GetTag_ids() []int { 14 | if r == nil { 15 | var zeroVal []int 16 | return zeroVal 17 | } 18 | return r.Tag_ids 19 | } 20 | 21 | func (r *ServiceListRequest) GetEnv_id() int { 22 | if r == nil { 23 | var zeroVal int 24 | return zeroVal 25 | } 26 | return r.Env_id 27 | } 28 | 29 | func (r *ServiceListRequest) GetOffset() int { 30 | if r == nil { 31 | var zeroVal int 32 | return zeroVal 33 | } 34 | return r.Offset 35 | } 36 | 37 | func (r *ServiceListRequest) GetLimit() int { 38 | if r == nil { 39 | var zeroVal int 40 | return zeroVal 41 | } 42 | return r.Limit 43 | } 44 | -------------------------------------------------------------------------------- /test/expected/app/modules/todolist/models/AddResp.php: -------------------------------------------------------------------------------- 1 | set_count ( $response["count"] ); 14 | } 15 | } 16 | 17 | public function validate() 18 | { 19 | if (!isset($this->count)) { 20 | throw new ProtoApi\GeneralException("'count' is not exist"); 21 | } 22 | } 23 | 24 | public function set_count(int $count) 25 | { 26 | $this->count = $count; 27 | } 28 | 29 | public function get_count() 30 | { 31 | return $this->count; 32 | } 33 | 34 | public function to_array() 35 | { 36 | return array( 37 | "count" => $this->count, 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <response->statusCode = 400; 14 | $resp = $exception->to_array(); 15 | } else if ($exception instanceof ProtoApi\CommonErrorException) { 16 | Yii::$app->response->statusCode = 420; 17 | $resp = $exception->to_array(); 18 | } else { 19 | Yii::$app->response->statusCode = 500; 20 | $resp = array( 21 | "message"=>$exception->getMessage(), 22 | "stack"=>$exception->getTraceAsString(), 23 | ); 24 | } 25 | Yii::$app->response->data = $resp; 26 | Yii::$app->response->send(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/SearchKeyValueListRequest.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class SearchKeyValueListRequest { 11 | private final String key; 12 | private final int service_id; 13 | private final int env_id; 14 | 15 | @JsonCreator 16 | public SearchKeyValueListRequest(@JsonProperty("key") String key, @JsonProperty("service_id") int service_id, @JsonProperty("env_id") int env_id) { 17 | this.key = key; 18 | this.service_id = service_id; 19 | this.env_id = env_id; 20 | } 21 | 22 | public String getKey() { 23 | return key; 24 | } 25 | public int getService_id() { 26 | return service_id; 27 | } 28 | public int getEnv_id() { 29 | return env_id; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/UpdateServiceRequest.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class UpdateServiceRequest { 11 | private final int service_id; 12 | private final List tags; 13 | private final String desc; 14 | 15 | @JsonCreator 16 | public UpdateServiceRequest(@JsonProperty("service_id") int service_id, @JsonProperty("tags") List tags, @JsonProperty("desc") String desc) { 17 | this.service_id = service_id; 18 | this.tags = tags; 19 | this.desc = desc; 20 | } 21 | 22 | public int getService_id() { 23 | return service_id; 24 | } 25 | public List getTags() { 26 | return tags; 27 | } 28 | public String getDesc() { 29 | return desc; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/UpdateServiceResponse.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class UpdateServiceResponse { 11 | private final int service_id; 12 | private final List tags; 13 | private final String desc; 14 | 15 | @JsonCreator 16 | public UpdateServiceResponse(@JsonProperty("service_id") int service_id, @JsonProperty("tags") List tags, @JsonProperty("desc") String desc) { 17 | this.service_id = service_id; 18 | this.tags = tags; 19 | this.desc = desc; 20 | } 21 | 22 | public int getService_id() { 23 | return service_id; 24 | } 25 | public List getTags() { 26 | return tags; 27 | } 28 | public String getDesc() { 29 | return desc; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/UploadProtoFileRequest.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class UploadProtoFileRequest { 11 | private final int service_id; 12 | private final int env_id; 13 | private final String file; 14 | 15 | @JsonCreator 16 | public UploadProtoFileRequest(@JsonProperty("service_id") int service_id, @JsonProperty("env_id") int env_id, @JsonProperty("file") String file) { 17 | this.service_id = service_id; 18 | this.env_id = env_id; 19 | this.file = file; 20 | } 21 | 22 | public int getService_id() { 23 | return service_id; 24 | } 25 | public int getEnv_id() { 26 | return env_id; 27 | } 28 | public String getFile() { 29 | return file; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/README.md: -------------------------------------------------------------------------------- 1 | # mousetrap 2 | 3 | mousetrap is a tiny library that answers a single question. 4 | 5 | On a Windows machine, was the process invoked by someone double clicking on 6 | the executable file while browsing in explorer? 7 | 8 | ### Motivation 9 | 10 | Windows developers unfamiliar with command line tools will often "double-click" 11 | the executable for a tool. Because most CLI tools print the help and then exit 12 | when invoked without arguments, this is often very frustrating for those users. 13 | 14 | mousetrap provides a way to detect these invocations so that you can provide 15 | more helpful behavior and instructions on how to run the CLI tool. To see what 16 | this looks like, both from an organizational and a technical perspective, see 17 | https://inconshreveable.com/09-09-2014/sweat-the-small-stuff/ 18 | 19 | ### The interface 20 | 21 | The library exposes a single interface: 22 | 23 | func StartedByExplorer() (bool) 24 | -------------------------------------------------------------------------------- /cmd/root.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | // RootCmd represents the base command when called without any subcommands 11 | var RootCmd = &cobra.Command{ 12 | Use: "protoapi", 13 | Short: "protoapi is a code generation command line tool", 14 | Long: `protoapi is a tool/document to help generate API code: 15 | 1. as a IDL, to document API request/response and function for developers' reference; 16 | 2. generate boilderplate code to save time and cost for developers`, 17 | Version: "0.1.1", 18 | } 19 | 20 | // Execute adds all child commands to the root command and sets flags appropriately. 21 | // This is called by main.main(). It only needs to happen once to the RootCmd. 22 | func Execute() { 23 | if err := RootCmd.Execute(); err != nil { 24 | fmt.Println(err) 25 | os.Exit(1) 26 | } 27 | } 28 | 29 | func init() { 30 | RootCmd.SetUsageFunc(usageFunc) 31 | RootCmd.SetHelpTemplate(`{{.UsageString}}`) 32 | } 33 | -------------------------------------------------------------------------------- /test/expected/app/modules/todolist/handlers/ErrorHandler.php: -------------------------------------------------------------------------------- 1 | response->statusCode = 400; 14 | $resp = $exception->to_array(); 15 | } else if ($exception instanceof ProtoApi\CommonErrorException) { 16 | Yii::$app->response->statusCode = 420; 17 | $resp = $exception->to_array(); 18 | } else { 19 | Yii::$app->response->statusCode = 500; 20 | $resp = array( 21 | "message"=>$exception->getMessage(), 22 | "stack"=>$exception->getTraceAsString(), 23 | ); 24 | } 25 | Yii::$app->response->data = $resp; 26 | Yii::$app->response->send(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/ServiceListResponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // ServiceListResponse 6 | type ServiceListResponse struct { 7 | Services []*Service `json:"services"` 8 | Offset int `json:"offset"` 9 | Limit int `json:"limit"` 10 | Total int `json:"total"` 11 | } 12 | 13 | func (r *ServiceListResponse) GetServices() []*Service { 14 | if r == nil { 15 | var zeroVal []*Service 16 | return zeroVal 17 | } 18 | return r.Services 19 | } 20 | 21 | func (r *ServiceListResponse) GetOffset() int { 22 | if r == nil { 23 | var zeroVal int 24 | return zeroVal 25 | } 26 | return r.Offset 27 | } 28 | 29 | func (r *ServiceListResponse) GetLimit() int { 30 | if r == nil { 31 | var zeroVal int 32 | return zeroVal 33 | } 34 | return r.Limit 35 | } 36 | 37 | func (r *ServiceListResponse) GetTotal() int { 38 | if r == nil { 39 | var zeroVal int 40 | return zeroVal 41 | } 42 | return r.Total 43 | } 44 | -------------------------------------------------------------------------------- /generator/template/spring_service.gojava: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package {{.Package}}; 4 | 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | 10 | public abstract class {{.Name}}Base { 11 | {{- range .Methods }} 12 | {{- if ne .ServiceType "GET" }} 13 | @PostMapping("{{.Path}}") 14 | @ResponseBody 15 | public {{.OutputType}} {{.Name}}Post(@RequestBody {{.InputType}} in) { 16 | return {{.Name}}(in); 17 | } 18 | {{- end }} 19 | 20 | {{- if ne .ServiceType "POST" }} 21 | @GetMapping("{{.Path}}") 22 | @ResponseBody 23 | public {{.OutputType}} {{.Name}}Get({{.InputType}} in) { 24 | return {{.Name}}(in); 25 | } 26 | {{- end }} 27 | 28 | abstract {{.OutputType}} {{.Name}}({{.InputType}} in); 29 | {{ end }} 30 | } 31 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/UploadProtoFileResponse.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class UploadProtoFileResponse { 11 | private final int service_id; 12 | private final int env_id; 13 | private final int key_count; 14 | 15 | @JsonCreator 16 | public UploadProtoFileResponse(@JsonProperty("service_id") int service_id, @JsonProperty("env_id") int env_id, @JsonProperty("key_count") int key_count) { 17 | this.service_id = service_id; 18 | this.env_id = env_id; 19 | this.key_count = key_count; 20 | } 21 | 22 | public int getService_id() { 23 | return service_id; 24 | } 25 | public int getEnv_id() { 26 | return env_id; 27 | } 28 | public int getKey_count() { 29 | return key_count; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/KVHistoryItem.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // KVHistoryItem 6 | type KVHistoryItem struct { 7 | Updated_value string `json:"updated_value"` 8 | Updated_date string `json:"updated_date"` 9 | Updated_by string `json:"updated_by"` 10 | Revision int64 `json:"revision"` 11 | } 12 | 13 | func (r *KVHistoryItem) GetUpdated_value() string { 14 | if r == nil { 15 | var zeroVal string 16 | return zeroVal 17 | } 18 | return r.Updated_value 19 | } 20 | 21 | func (r *KVHistoryItem) GetUpdated_date() string { 22 | if r == nil { 23 | var zeroVal string 24 | return zeroVal 25 | } 26 | return r.Updated_date 27 | } 28 | 29 | func (r *KVHistoryItem) GetUpdated_by() string { 30 | if r == nil { 31 | var zeroVal string 32 | return zeroVal 33 | } 34 | return r.Updated_by 35 | } 36 | 37 | func (r *KVHistoryItem) GetRevision() int64 { 38 | if r == nil { 39 | var zeroVal int64 40 | return zeroVal 41 | } 42 | return r.Revision 43 | } 44 | -------------------------------------------------------------------------------- /generator/template/ts/helper_fetch.gots: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * 4 | * @param {response} response the error response 5 | */ 6 | export async function errorHandling(error): Promise { 7 | if(!error) { 8 | return error 9 | } 10 | if (!!error.data && typeof error.data === 'object') { 11 | if (error.data.message) { 12 | error.message = error.data.message 13 | } 14 | switch (error.status) { 15 | case httpCode.BIZ_ERROR: 16 | return error; 17 | case httpCode.COMMON_ERROR: 18 | const returnErr = (() => { 19 | try { 20 | return mapCommonErrorType(error.data); 21 | } catch (e) { 22 | return undefined; 23 | } 24 | })() 25 | if(!returnErr){ 26 | return error; 27 | } 28 | return ({...error, ...returnErr}); 29 | } 30 | } 31 | return error; 32 | } -------------------------------------------------------------------------------- /test/expected/app/modules/todolist/models/AddReq.php: -------------------------------------------------------------------------------- 1 | item = new Todo(); 14 | $this->item->init($response["item"]); 15 | } 16 | } 17 | 18 | public function validate() 19 | { 20 | if (!isset($this->item)) { 21 | throw new ProtoApi\GeneralException("'item' is not exist"); 22 | } 23 | $this->item->validate(); 24 | } 25 | 26 | public function set_item(Todo $item) 27 | { 28 | $this->item = $item; 29 | } 30 | 31 | public function get_item() 32 | { 33 | return $this->item; 34 | } 35 | 36 | public function to_array() 37 | { 38 | return array( 39 | "item" => $this->item->to_array(), 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/expected/app/modules/todolist/models/AuthError.php: -------------------------------------------------------------------------------- 1 | set_message ( $response["message"] ); 15 | } 16 | } 17 | 18 | public function validate() 19 | { 20 | if (!isset($this->message)) { 21 | throw new ProtoApi\GeneralException("'message' is not exist"); 22 | } 23 | } 24 | 25 | public function set_message(string $message) 26 | { 27 | $this->message = $message; 28 | } 29 | 30 | public function get_message() 31 | { 32 | return $this->message; 33 | } 34 | 35 | public function to_array() 36 | { 37 | return array( 38 | "message" => $this->message, 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/expected/app/modules/todolist/models/BindError.php: -------------------------------------------------------------------------------- 1 | set_message ( $response["message"] ); 15 | } 16 | } 17 | 18 | public function validate() 19 | { 20 | if (!isset($this->message)) { 21 | throw new ProtoApi\GeneralException("'message' is not exist"); 22 | } 23 | } 24 | 25 | public function set_message(string $message) 26 | { 27 | $this->message = $message; 28 | } 29 | 30 | public function get_message() 31 | { 32 | return $this->message; 33 | } 34 | 35 | public function to_array() 36 | { 37 | return array( 38 | "message" => $this->message, 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/expected/app/modules/todolist/models/GenericError.php: -------------------------------------------------------------------------------- 1 | set_message ( $response["message"] ); 15 | } 16 | } 17 | 18 | public function validate() 19 | { 20 | if (!isset($this->message)) { 21 | throw new ProtoApi\GeneralException("'message' is not exist"); 22 | } 23 | } 24 | 25 | public function set_message(string $message) 26 | { 27 | $this->message = $message; 28 | } 29 | 30 | public function get_message() 31 | { 32 | return $this->message; 33 | } 34 | 35 | public function to_array() 36 | { 37 | return array( 38 | "message" => $this->message, 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /generator/output/echo_v4.go: -------------------------------------------------------------------------------- 1 | package output 2 | 3 | import ( 4 | "github.com/yoozoo/protoapi/generator/data" 5 | ) 6 | 7 | type echoV4Gen struct { 8 | goGen 9 | } 10 | 11 | func (g *echoV4Gen) Gen(applicationName string, packageName string, services []*data.ServiceData, messages []*data.MessageData, enums []*data.EnumData, options data.OptionMap) (result map[string]string, err error) { 12 | g.DataTypes = messages 13 | serviceResult := make(map[string]string) 14 | for _, service := range services { 15 | g.serviceTpl = g.getTpl("/generator/template/echo_v4/service.gogo") 16 | serviceContent := g.genGoService(service) 17 | serviceFilename := genEchoFileName(g.PackageName, service) 18 | g.serviceTpl = nil 19 | serviceResult[serviceFilename] = serviceContent 20 | } 21 | 22 | result, err = g.echoGen.Gen(applicationName, packageName, services, messages, enums, options) 23 | for k, v := range serviceResult { 24 | result[k] = v 25 | } 26 | 27 | return 28 | } 29 | 30 | func init() { 31 | data.OutputMap["echo_v4"] = &echoV4Gen{} 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/valyala/bytebufferpool/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/valyala/bytebufferpool.svg)](https://travis-ci.org/valyala/bytebufferpool) 2 | [![GoDoc](https://godoc.org/github.com/valyala/bytebufferpool?status.svg)](http://godoc.org/github.com/valyala/bytebufferpool) 3 | [![Go Report](http://goreportcard.com/badge/valyala/bytebufferpool)](http://goreportcard.com/report/valyala/bytebufferpool) 4 | 5 | # bytebufferpool 6 | 7 | An implementation of a pool of byte buffers with anti-memory-waste protection. 8 | 9 | The pool may waste limited amount of memory due to fragmentation. 10 | This amount equals to the maximum total size of the byte buffers 11 | in concurrent use. 12 | 13 | # Benchmark results 14 | Currently bytebufferpool is fastest and most effective buffer pool written in Go. 15 | 16 | You can find results [here](https://omgnull.github.io/go-benchmark/buffer/). 17 | 18 | # bytebufferpool users 19 | 20 | * [fasthttp](https://github.com/valyala/fasthttp) 21 | * [quicktemplate](https://github.com/valyala/quicktemplate) 22 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/RegisterServiceResponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // RegisterServiceResponse 6 | type RegisterServiceResponse struct { 7 | Env_id int `json:"env_id"` 8 | Product_id string `json:"product_id"` 9 | Service_id int `json:"service_id"` 10 | Service_name string `json:"service_name"` 11 | } 12 | 13 | func (r *RegisterServiceResponse) GetEnv_id() int { 14 | if r == nil { 15 | var zeroVal int 16 | return zeroVal 17 | } 18 | return r.Env_id 19 | } 20 | 21 | func (r *RegisterServiceResponse) GetProduct_id() string { 22 | if r == nil { 23 | var zeroVal string 24 | return zeroVal 25 | } 26 | return r.Product_id 27 | } 28 | 29 | func (r *RegisterServiceResponse) GetService_id() int { 30 | if r == nil { 31 | var zeroVal int 32 | return zeroVal 33 | } 34 | return r.Service_id 35 | } 36 | 37 | func (r *RegisterServiceResponse) GetService_name() string { 38 | if r == nil { 39 | var zeroVal string 40 | return zeroVal 41 | } 42 | return r.Service_name 43 | } 44 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /generator/output/spring_service.go: -------------------------------------------------------------------------------- 1 | package output 2 | 3 | import ( 4 | "github.com/yoozoo/protoapi/generator/data" 5 | ) 6 | 7 | type springMethod struct { 8 | *data.Method 9 | ServiceName string 10 | } 11 | 12 | func (m *springMethod) Path() string { 13 | return "/" + m.ServiceName + "." + m.Name 14 | } 15 | 16 | func (m *springMethod) ServiceType() string { 17 | if servType, ok := m.Options[data.MethodOptions[data.ServiceTypeMethodOption].Name]; ok { 18 | return servType 19 | } 20 | 21 | return "POST" 22 | } 23 | 24 | type springService struct { 25 | *data.ServiceData 26 | Package string 27 | Methods []*springMethod 28 | } 29 | 30 | func newSpringService(msg *data.ServiceData, packageName string) *springService { 31 | o := &springService{ 32 | msg, 33 | packageName, 34 | nil, 35 | } 36 | o.init() 37 | return o 38 | } 39 | 40 | func (s *springService) init() { 41 | s.Methods = make([]*springMethod, len(s.ServiceData.Methods)) 42 | for i, f := range s.ServiceData.Methods { 43 | mtd := f 44 | s.Methods[i] = &springMethod{mtd, s.Name} 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /test/expected/go/calcsvr/CommonError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvr 4 | 5 | // CommonError 6 | type CommonError struct { 7 | GenericError *GenericError `json:"genericError"` 8 | AuthError *AuthError `json:"authError"` 9 | ValidateError *ValidateError `json:"validateError"` 10 | BindError *BindError `json:"bindError"` 11 | } 12 | 13 | func (r *CommonError) GetGenericError() *GenericError { 14 | if r == nil { 15 | var zeroVal *GenericError 16 | return zeroVal 17 | } 18 | return r.GenericError 19 | } 20 | 21 | func (r *CommonError) GetAuthError() *AuthError { 22 | if r == nil { 23 | var zeroVal *AuthError 24 | return zeroVal 25 | } 26 | return r.AuthError 27 | } 28 | 29 | func (r *CommonError) GetValidateError() *ValidateError { 30 | if r == nil { 31 | var zeroVal *ValidateError 32 | return zeroVal 33 | } 34 | return r.ValidateError 35 | } 36 | 37 | func (r *CommonError) GetBindError() *BindError { 38 | if r == nil { 39 | var zeroVal *BindError 40 | return zeroVal 41 | } 42 | return r.BindError 43 | } 44 | -------------------------------------------------------------------------------- /test/expected/go/nested/CommonError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package nested 4 | 5 | // CommonError 6 | type CommonError struct { 7 | GenericError *GenericError `json:"genericError"` 8 | AuthError *AuthError `json:"authError"` 9 | ValidateError *ValidateError `json:"validateError"` 10 | BindError *BindError `json:"bindError"` 11 | } 12 | 13 | func (r *CommonError) GetGenericError() *GenericError { 14 | if r == nil { 15 | var zeroVal *GenericError 16 | return zeroVal 17 | } 18 | return r.GenericError 19 | } 20 | 21 | func (r *CommonError) GetAuthError() *AuthError { 22 | if r == nil { 23 | var zeroVal *AuthError 24 | return zeroVal 25 | } 26 | return r.AuthError 27 | } 28 | 29 | func (r *CommonError) GetValidateError() *ValidateError { 30 | if r == nil { 31 | var zeroVal *ValidateError 32 | return zeroVal 33 | } 34 | return r.ValidateError 35 | } 36 | 37 | func (r *CommonError) GetBindError() *BindError { 38 | if r == nil { 39 | var zeroVal *BindError 40 | return zeroVal 41 | } 42 | return r.BindError 43 | } 44 | -------------------------------------------------------------------------------- /test/expected/package/go/common/CommonError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package common 4 | 5 | // CommonError 6 | type CommonError struct { 7 | GenericError *GenericError `json:"genericError"` 8 | AuthError *AuthError `json:"authError"` 9 | ValidateError *ValidateError `json:"validateError"` 10 | BindError *BindError `json:"bindError"` 11 | } 12 | 13 | func (r *CommonError) GetGenericError() *GenericError { 14 | if r == nil { 15 | var zeroVal *GenericError 16 | return zeroVal 17 | } 18 | return r.GenericError 19 | } 20 | 21 | func (r *CommonError) GetAuthError() *AuthError { 22 | if r == nil { 23 | var zeroVal *AuthError 24 | return zeroVal 25 | } 26 | return r.AuthError 27 | } 28 | 29 | func (r *CommonError) GetValidateError() *ValidateError { 30 | if r == nil { 31 | var zeroVal *ValidateError 32 | return zeroVal 33 | } 34 | return r.ValidateError 35 | } 36 | 37 | func (r *CommonError) GetBindError() *BindError { 38 | if r == nil { 39 | var zeroVal *BindError 40 | return zeroVal 41 | } 42 | return r.BindError 43 | } 44 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/Key.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // Key 6 | type Key struct { 7 | Key_id int `json:"key_id"` 8 | Key string `json:"key"` 9 | DataType string `json:"dataType"` 10 | DefaultValue string `json:"defaultValue"` 11 | IsWatched bool `json:"isWatched"` 12 | } 13 | 14 | func (r *Key) GetKey_id() int { 15 | if r == nil { 16 | var zeroVal int 17 | return zeroVal 18 | } 19 | return r.Key_id 20 | } 21 | 22 | func (r *Key) GetKey() string { 23 | if r == nil { 24 | var zeroVal string 25 | return zeroVal 26 | } 27 | return r.Key 28 | } 29 | 30 | func (r *Key) GetDataType() string { 31 | if r == nil { 32 | var zeroVal string 33 | return zeroVal 34 | } 35 | return r.DataType 36 | } 37 | 38 | func (r *Key) GetDefaultValue() string { 39 | if r == nil { 40 | var zeroVal string 41 | return zeroVal 42 | } 43 | return r.DefaultValue 44 | } 45 | 46 | func (r *Key) GetIsWatched() bool { 47 | if r == nil { 48 | var zeroVal bool 49 | return zeroVal 50 | } 51 | return r.IsWatched 52 | } 53 | -------------------------------------------------------------------------------- /test/simple.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "protoapi_common.proto"; 8 | 9 | // package 10 | package yoozoo.protoconf.ts; 11 | option java_package = "com.yoozoo.spring"; 12 | 13 | // env list - 环境 14 | message EnvListRequest { 15 | } 16 | 17 | message EnvListResponse { 18 | repeated Env envs = 1; 19 | } 20 | 21 | message Env { 22 | string env_name = 1; 23 | int32 env_id = 2; 24 | } 25 | 26 | message Error { 27 | ErrorCode code = 1; 28 | string message = 2; 29 | } 30 | 31 | enum ErrorCode { 32 | DefaultError = 0; 33 | GeneralError = 1000; 34 | DatabaseError = 1001; 35 | EtcdError = 1002; 36 | SystemError = 1003; 37 | } 38 | 39 | /** 40 | * This service contains all the rpc related with services 41 | * option (service_method) can be "POST" or "GET", if not specified, both post and get methods will be supported 42 | */ 43 | service AppService { 44 | // get env 45 | rpc getEnv (EnvListRequest) returns (EnvListResponse) { 46 | option (error) = "Error"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "runtime" 10 | 11 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 12 | // 13 | // To change fd's window size, the req argument should be TIOCSWINSZ. 14 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 15 | // TODO: if we get the chance, remove the req parameter and 16 | // hardcode TIOCSWINSZ. 17 | err := ioctlSetWinsize(fd, req, value) 18 | runtime.KeepAlive(value) 19 | return err 20 | } 21 | 22 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 23 | // 24 | // The req value will usually be TCSETA or TIOCSETA. 25 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 26 | // TODO: if we get the chance, remove the req parameter. 27 | err := ioctlSetTermios(fd, req, value) 28 | runtime.KeepAlive(value) 29 | return err 30 | } 31 | -------------------------------------------------------------------------------- /proto/protoapi_common.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/descriptor.proto"; 4 | 5 | extend google.protobuf.MethodOptions { 6 | string service_method = 51006; 7 | string error = 51007; 8 | } 9 | 10 | extend google.protobuf.ServiceOptions { 11 | string common_error = 51008; 12 | bool auth = 51009; 13 | } 14 | 15 | extend google.protobuf.FieldOptions { 16 | string val_format = 51002; 17 | bool val_required = 51003; 18 | int32 min = 51004; 19 | int32 max = 51005; 20 | } 21 | 22 | message CommonError { 23 | GenericError genericError = 1; 24 | AuthError authError = 2; 25 | ValidateError validateError = 3; 26 | BindError bindError = 4; 27 | } 28 | 29 | message GenericError { string message = 1; } 30 | 31 | message AuthError { string message = 1; } 32 | 33 | message BindError { string message = 1; } 34 | 35 | message ValidateError { repeated FieldError errors = 1; } 36 | 37 | message FieldError { 38 | string fieldName = 1; 39 | ValidateErrorType errorType = 2; 40 | } 41 | 42 | enum ValidateErrorType { 43 | INVALID_EMAIL = 0; 44 | FIELD_REQUIRED = 1; 45 | } 46 | -------------------------------------------------------------------------------- /test/expected/package/go/calcsvrmain/CommonError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvrmain 4 | 5 | // CommonError 6 | type CommonError struct { 7 | GenericError *GenericError `json:"genericError"` 8 | AuthError *AuthError `json:"authError"` 9 | ValidateError *ValidateError `json:"validateError"` 10 | BindError *BindError `json:"bindError"` 11 | } 12 | 13 | func (r *CommonError) GetGenericError() *GenericError { 14 | if r == nil { 15 | var zeroVal *GenericError 16 | return zeroVal 17 | } 18 | return r.GenericError 19 | } 20 | 21 | func (r *CommonError) GetAuthError() *AuthError { 22 | if r == nil { 23 | var zeroVal *AuthError 24 | return zeroVal 25 | } 26 | return r.AuthError 27 | } 28 | 29 | func (r *CommonError) GetValidateError() *ValidateError { 30 | if r == nil { 31 | var zeroVal *ValidateError 32 | return zeroVal 33 | } 34 | return r.ValidateError 35 | } 36 | 37 | func (r *CommonError) GetBindError() *BindError { 38 | if r == nil { 39 | var zeroVal *BindError 40 | return zeroVal 41 | } 42 | return r.BindError 43 | } 44 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc64 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: sec, Nsec: nsec} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /protoapigo/json_api_binder.go: -------------------------------------------------------------------------------- 1 | package protoapigo 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/http" 7 | 8 | "github.com/labstack/echo" 9 | ) 10 | 11 | // JSONAPIBinder is a Binder to echo design for JSON API 12 | type JSONAPIBinder struct { 13 | *echo.DefaultBinder 14 | } 15 | 16 | // Bind use json decoder for all context type & DisallowUnknownFields 17 | func (b *JSONAPIBinder) Bind(i interface{}, c echo.Context) (err error) { 18 | req := c.Request() 19 | d := json.NewDecoder(req.Body) 20 | d.DisallowUnknownFields() 21 | if err = d.Decode(i); err != nil { 22 | if ute, ok := err.(*json.UnmarshalTypeError); ok { 23 | return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unmarshal type error: expected=%v, got=%v, offset=%v", ute.Type, ute.Value, ute.Offset)) 24 | } else if se, ok := err.(*json.SyntaxError); ok { 25 | return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: offset=%v, error=%v", se.Offset, se.Error())) 26 | } else { 27 | return echo.NewHTTPError(http.StatusBadRequest, err.Error()) 28 | } 29 | } 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /test/expected/package/go/calcsvrmain_without/CommonError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package calcsvrmain_without 4 | 5 | // CommonError 6 | type CommonError struct { 7 | GenericError *GenericError `json:"genericError"` 8 | AuthError *AuthError `json:"authError"` 9 | ValidateError *ValidateError `json:"validateError"` 10 | BindError *BindError `json:"bindError"` 11 | } 12 | 13 | func (r *CommonError) GetGenericError() *GenericError { 14 | if r == nil { 15 | var zeroVal *GenericError 16 | return zeroVal 17 | } 18 | return r.GenericError 19 | } 20 | 21 | func (r *CommonError) GetAuthError() *AuthError { 22 | if r == nil { 23 | var zeroVal *AuthError 24 | return zeroVal 25 | } 26 | return r.AuthError 27 | } 28 | 29 | func (r *CommonError) GetValidateError() *ValidateError { 30 | if r == nil { 31 | var zeroVal *ValidateError 32 | return zeroVal 33 | } 34 | return r.ValidateError 35 | } 36 | 37 | func (r *CommonError) GetBindError() *BindError { 38 | if r == nil { 39 | var zeroVal *BindError 40 | return zeroVal 41 | } 42 | return r.BindError 43 | } 44 | -------------------------------------------------------------------------------- /test/proto/common.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/descriptor.proto"; 4 | 5 | extend google.protobuf.MethodOptions { 6 | string service_method = 51006; 7 | string error = 51007; 8 | } 9 | 10 | extend google.protobuf.ServiceOptions { 11 | string common_error = 51008; 12 | bool auth = 51009; 13 | } 14 | 15 | extend google.protobuf.FieldOptions { 16 | string val_format = 51002; 17 | bool val_required = 51003; 18 | int32 min = 51004; 19 | int32 max = 51005; 20 | } 21 | 22 | message CommonError { 23 | GenericError genericError = 1; 24 | AuthError authError = 2; 25 | ValidateError validateError = 3; 26 | BindError bindError = 4; 27 | } 28 | 29 | message GenericError { string message = 1; } 30 | 31 | message AuthError { string message = 1; } 32 | 33 | message BindError { string message = 1; } 34 | 35 | message ValidateError { repeated FieldError errors = 1; } 36 | 37 | message FieldError { 38 | string fieldName = 1; 39 | ValidateErrorType errorType = 2; 40 | } 41 | 42 | enum ValidateErrorType { 43 | INVALID_EMAIL = 0; 44 | FIELD_REQUIRED = 1; 45 | } 46 | 47 | message Empty {} 48 | -------------------------------------------------------------------------------- /generator/template/echo_struct.gogo: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package {{.Package}} 4 | 5 | // {{.ClassName}} 6 | type {{.ClassName}} struct { 7 | {{- range .Fields }} 8 | {{.Title}} {{.Type}} `json:"{{.Name}}"` 9 | {{- end }} 10 | } 11 | {{- range .Fields }} 12 | 13 | func (r *{{$.ClassName}}) Get{{.Title}}() {{.Type}} { 14 | if r == nil { 15 | var zeroVal {{.Type}} 16 | return zeroVal 17 | } 18 | return r.{{.Title}} 19 | } 20 | {{- end }} 21 | 22 | func (r {{.ClassName}}) Validate() *ValidateError { 23 | errs := []*FieldError{} 24 | {{- range .Fields }} 25 | {{- if .ValidateRequired }} 26 | if r.{{.Title}} == "" { 27 | e := FIELD_REQUIRED 28 | errs = append(errs, &FieldError{FieldName: r.{{.Title}}, ErrorType: &e}) 29 | } 30 | {{- end }} 31 | {{- if eq .ValidateFormat "email" }} 32 | if !rxEmail.MatchString(r.{{.Title}}) { 33 | e := INVALID_EMAIL 34 | errs = append(errs, &FieldError{FieldName: r.{{.Title}}, ErrorType: &e}) 35 | } 36 | {{- end }} 37 | {{- end }} 38 | if len(errs) > 0 { 39 | return &ValidateError{Errors: errs} 40 | } 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 yoozoo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix 6 | // +build ppc 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 16 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 17 | valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg)) 18 | var err error 19 | if errno != 0 { 20 | err = errno 21 | } 22 | return int(valptr), err 23 | } 24 | 25 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 26 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 27 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 28 | if errno == 0 { 29 | return nil 30 | } 31 | return errno 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,gccgo,386 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | 22 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 23 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 24 | return int(fd), err 25 | } 26 | 27 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 28 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 29 | return int(fd), err 30 | } 31 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/ServiceListRequest.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class ServiceListRequest { 11 | private final List tag_ids; 12 | private final int env_id; 13 | private final int offset; 14 | private final int limit; 15 | 16 | @JsonCreator 17 | public ServiceListRequest(@JsonProperty("tag_ids") List tag_ids, @JsonProperty("env_id") int env_id, @JsonProperty("offset") int offset, @JsonProperty("limit") int limit) { 18 | this.tag_ids = tag_ids; 19 | this.env_id = env_id; 20 | this.offset = offset; 21 | this.limit = limit; 22 | } 23 | 24 | public List getTag_ids() { 25 | return tag_ids; 26 | } 27 | public int getEnv_id() { 28 | return env_id; 29 | } 30 | public int getOffset() { 31 | return offset; 32 | } 33 | public int getLimit() { 34 | return limit; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /test/expected/com/yoozoo/spring/ServiceListResponse.java: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi; DO NOT EDIT. 2 | 3 | package com.yoozoo.spring; 4 | 5 | import com.fasterxml.jackson.annotation.JsonCreator; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | import java.util.List; 9 | 10 | public class ServiceListResponse { 11 | private final List services; 12 | private final int offset; 13 | private final int limit; 14 | private final int total; 15 | 16 | @JsonCreator 17 | public ServiceListResponse(@JsonProperty("services") List services, @JsonProperty("offset") int offset, @JsonProperty("limit") int limit, @JsonProperty("total") int total) { 18 | this.services = services; 19 | this.offset = offset; 20 | this.limit = limit; 21 | this.total = total; 22 | } 23 | 24 | public List getServices() { 25 | return services; 26 | } 27 | public int getOffset() { 28 | return offset; 29 | } 30 | public int getLimit() { 31 | return limit; 32 | } 33 | public int getTotal() { 34 | return total; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/CommonError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | // CommonError 6 | type CommonError struct { 7 | GenericError *GenericError `json:"genericError"` 8 | AuthError *AuthError `json:"authError"` 9 | ValidateError *ValidateError `json:"validateError"` 10 | BindError *BindError `json:"bindError"` 11 | } 12 | 13 | func (r *CommonError) GetGenericError() *GenericError { 14 | if r == nil { 15 | var zeroVal *GenericError 16 | return zeroVal 17 | } 18 | return r.GenericError 19 | } 20 | 21 | func (r *CommonError) GetAuthError() *AuthError { 22 | if r == nil { 23 | var zeroVal *AuthError 24 | return zeroVal 25 | } 26 | return r.AuthError 27 | } 28 | 29 | func (r *CommonError) GetValidateError() *ValidateError { 30 | if r == nil { 31 | var zeroVal *ValidateError 32 | return zeroVal 33 | } 34 | return r.ValidateError 35 | } 36 | 37 | func (r *CommonError) GetBindError() *BindError { 38 | if r == nil { 39 | var zeroVal *BindError 40 | return zeroVal 41 | } 42 | return r.BindError 43 | } 44 | 45 | func (r *CommonError) Error() string { 46 | return "Error" 47 | } 48 | -------------------------------------------------------------------------------- /test/proto/package/common.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/descriptor.proto"; 4 | 5 | package common; 6 | 7 | extend google.protobuf.MethodOptions { 8 | string service_method = 51006; 9 | string error = 51007; 10 | } 11 | 12 | extend google.protobuf.ServiceOptions { 13 | string common_error = 51008; 14 | bool auth = 51009; 15 | } 16 | 17 | extend google.protobuf.FieldOptions { 18 | string val_format = 51002; 19 | bool val_required = 51003; 20 | int32 min = 51004; 21 | int32 max = 51005; 22 | } 23 | 24 | message CommonError { 25 | GenericError genericError = 1; 26 | AuthError authError = 2; 27 | ValidateError validateError = 3; 28 | BindError bindError = 4; 29 | } 30 | 31 | message GenericError { string message = 1; } 32 | 33 | message AuthError { string message = 1; } 34 | 35 | message BindError { string message = 1; } 36 | 37 | message ValidateError { repeated FieldError errors = 1; } 38 | 39 | message FieldError { 40 | string fieldName = 1; 41 | ValidateErrorType errorType = 2; 42 | } 43 | 44 | enum ValidateErrorType { 45 | INVALID_EMAIL = 0; 46 | FIELD_REQUIRED = 1; 47 | } 48 | 49 | message Empty {} 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /test/expected/go/todolistsvr/CommonError.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package todolistsvr 4 | 5 | // CommonError 6 | type CommonError struct { 7 | GenericError *GenericError `json:"genericError"` 8 | AuthError *AuthError `json:"authError"` 9 | ValidateError *ValidateError `json:"validateError"` 10 | BindError *BindError `json:"bindError"` 11 | } 12 | 13 | func (r *CommonError) GetGenericError() *GenericError { 14 | if r == nil { 15 | var zeroVal *GenericError 16 | return zeroVal 17 | } 18 | return r.GenericError 19 | } 20 | 21 | func (r *CommonError) GetAuthError() *AuthError { 22 | if r == nil { 23 | var zeroVal *AuthError 24 | return zeroVal 25 | } 26 | return r.AuthError 27 | } 28 | 29 | func (r *CommonError) GetValidateError() *ValidateError { 30 | if r == nil { 31 | var zeroVal *ValidateError 32 | return zeroVal 33 | } 34 | return r.ValidateError 35 | } 36 | 37 | func (r *CommonError) GetBindError() *BindError { 38 | if r == nil { 39 | var zeroVal *BindError 40 | return zeroVal 41 | } 42 | return r.BindError 43 | } 44 | 45 | func (r *CommonError) Error() string { 46 | return "Error" 47 | } 48 | -------------------------------------------------------------------------------- /test/test_todolist.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/labstack/echo" 5 | "github.com/yoozoo/protoapi/test/result/go/todolistsvr" 6 | ) 7 | 8 | type todolistService struct { 9 | items []*todolistsvr.Todo 10 | } 11 | 12 | func (s *todolistService) Add(c echo.Context, req *todolistsvr.AddReq) (resp *todolistsvr.AddResp, bizError *todolistsvr.AddError, err error) { 13 | if len(s.items) > 4 { 14 | bizError = new(todolistsvr.AddError) 15 | bizError.Req = req 16 | bizError.Error = "Can't add more than 5 todos" 17 | return 18 | } 19 | 20 | if req.Item == nil { 21 | e := new(todolistsvr.CommonError) 22 | err = e 23 | return 24 | } 25 | 26 | s.items = append(s.items, req.Item) 27 | resp = new(todolistsvr.AddResp) 28 | resp.Count = len(s.items) 29 | return 30 | } 31 | 32 | func (s *todolistService) List(c echo.Context, req *todolistsvr.Empty) (resp *todolistsvr.ListResp, err error) { 33 | resp = new(todolistsvr.ListResp) 34 | resp.Items = s.items 35 | return 36 | } 37 | 38 | func main() { 39 | e := echo.New() 40 | 41 | srv := &todolistService{} 42 | todolistsvr.RegisterTodolistService(e, srv) 43 | 44 | e.Logger.Fatal(e.Start(":8080")) 45 | } 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /test/proto/login.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * 这个文件用于生成相关的前后端API代码 3 | * 用protoapi指定此文件生成相关代码 4 | */ 5 | syntax = "proto3"; 6 | 7 | import "common.proto"; 8 | 9 | message LoginReq { 10 | string account = 1; //Account name 11 | /* 12 | game id refer to game table 13 | */ 14 | int32 game_id = 2; 15 | //operation Id 16 | int32 op_id = 3; // test table 17 | int32 server_id = 4; 18 | } 19 | 20 | // login request return 21 | message LoginResp { 22 | int32 code = 1; 23 | string msg = 2; 24 | LoginInfo loginInfo = 3; 25 | repeated string data = 4; 26 | } 27 | 28 | message AccountInfo { 29 | string account_name = 1; 30 | string join_time = 2; 31 | } 32 | 33 | message LoginInfo { 34 | string user_id = 1; 35 | string last_login = 2; 36 | bool is_vip = 3; 37 | repeated AccountInfo accountInfo = 4; 38 | VipStatus vipStatus = 5; //this is an enum 39 | } 40 | 41 | 42 | 43 | enum VipStatus { 44 | UNKNOWN = 0; //default value for status 45 | VIP_1 = 1; 46 | VIP_2 = 2; 47 | } 48 | 49 | //test service comment 50 | service LoginService { 51 | //test method comment 52 | rpc logingame(LoginReq) returns (LoginResp) { 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /test/expected/go/apisvr/ErrorCode.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoapi:go; DO NOT EDIT. 2 | 3 | package apisvr 4 | 5 | type ErrorCode int 6 | 7 | const ( 8 | DefaultError ErrorCode = 0 9 | GeneralError ErrorCode = 1000 10 | DatabaseError ErrorCode = 1001 11 | EtcdError ErrorCode = 1002 12 | SystemError ErrorCode = 1003 13 | ) 14 | 15 | func (code ErrorCode) String() string { 16 | names := map[ErrorCode]string{ 17 | DefaultError: "DefaultError", 18 | GeneralError: "GeneralError", 19 | DatabaseError: "DatabaseError", 20 | EtcdError: "EtcdError", 21 | SystemError: "SystemError", 22 | } 23 | 24 | return names[code] 25 | } 26 | 27 | func (code ErrorCode) Code() int { 28 | return (int)(code) 29 | } 30 | 31 | func (code ErrorCode) IsDefaultError() bool { 32 | return code == DefaultError 33 | } 34 | 35 | func (code ErrorCode) IsGeneralError() bool { 36 | return code == GeneralError 37 | } 38 | 39 | func (code ErrorCode) IsDatabaseError() bool { 40 | return code == DatabaseError 41 | } 42 | 43 | func (code ErrorCode) IsEtcdError() bool { 44 | return code == EtcdError 45 | } 46 | 47 | func (code ErrorCode) IsSystemError() bool { 48 | return code == SystemError 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/valyala/fasttemplate/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Aliaksandr Valialkin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /test/expected/app/modules/todolist/models/ListResp.php: -------------------------------------------------------------------------------- 1 | set_items( array_map( function($v) { $tmp = new Todo(); $tmp->init($v); return $tmp; }, $val) ); 15 | } 16 | } 17 | 18 | public function validate() 19 | { 20 | if (!isset($this->items)) { 21 | throw new ProtoApi\GeneralException("'items' is not exist"); 22 | } 23 | array_filter($this->items, function($v) { $v->validate(); return false; }); 24 | } 25 | 26 | public function set_items(array $items) 27 | { 28 | $this->items = $items; 29 | } 30 | 31 | public function get_items() 32 | { 33 | return $this->items; 34 | } 35 | 36 | public function to_array() 37 | { 38 | return array( 39 | "items" => array_map( function ($v) { return $v->to_array(); }, $this->items), 40 | ); 41 | } 42 | } 43 | --------------------------------------------------------------------------------