fix templates

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-02-02 11:13:29 +03:00
parent 31e99273ca
commit e173bffd10
8 changed files with 44 additions and 42 deletions

View File

@@ -2,9 +2,26 @@
// source: {{.File.Name}}
package {{goPkgLastElement .File | splitArray ";" | last | replace "." "_"}}
{{- $File := .File }}
{{- $ServiceName := .Service.Name | trimSuffix "Service" }}
{{- $errmsg := list }}
{{range .Service.Method}}
{{- if not (contains (json (openapiOption .)) "null") }}
{{- if (openapiOption .).Responses }}
{{ range $k, $v := (openapiOption .).Responses }}
{{- $msgtype := (getMessageType $File $v.Schema.JsonSchema.Ref) }}
{{- $errmsg = append $errmsg $msgtype.Name }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
import (
"context"
{{- if ne (lenght $errmsg) 0 }}
"fmt"
{{- end }}
micro_client "github.com/unistack-org/micro/v3/client"
micro_server "github.com/unistack-org/micro/v3/server"
@@ -16,9 +33,6 @@ var (
_ micro_client.Option
)
{{- $File := .File }}
{{- $ServiceName := .Service.Name | trimSuffix "Service" }}
type {{$ServiceName | lowerFirst}}Service struct {
c micro_client.Client
name string
@@ -211,19 +225,6 @@ func (x *{{$ServiceName | lowerFirst}}{{.Name}}Stream) Recv() (*{{$reqMethod}},
{{end}}
{{end}}
{{- $errmsg := list }}
{{range .Service.Method}}
{{- if not (contains (json (openapiOption .)) "null") }}
{{- if (openapiOption .).Responses }}
{{ range $k, $v := (openapiOption .).Responses }}
{{- $msgtype := (getMessageType $File $v.Schema.JsonSchema.Ref) }}
{{- $errmsg = append $errmsg $msgtype.Name }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{range $k, $v := ($errmsg | uniq) }}
// Error method to satisfy error interface
func (e *{{- $v }}) Error() string {