Merge pull request #63 from runzexia/update-template

Update template to fit snips change
This commit is contained in:
runzexia 2017-11-10 14:46:36 +08:00 committed by GitHub
commit a8cf7b7324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -47,16 +47,14 @@ lint:
generate: snips ../qingcloud-api-specs/package.json
./snips \
-s=${shell go env GOPATH}/src/github.com/yunify \
-m=qingcloud-api-specs \
-n=2013-08-30 \
-f=../qingcloud-api-specs/2013-08-30/swagger/api_v2.0.json \
-t=./template \
-o=./service
go fmt ./service/...
@echo "ok"
snips:
curl -L https://github.com/yunify/snips/releases/download/v0.0.9/snips-v0.0.9-${shell go env GOOS}_amd64.tar.gz | tar zx
curl -L https://github.com/yunify/snips/releases/download/v0.2.16/snips-v0.2.16-${shell go env GOOS}_amd64.tar.gz | tar zx
../qingcloud-api-specs/package.json:
-go get -d github.com/yunify/qingcloud-api-specs

View File

@ -121,14 +121,14 @@
}
type {{$opID}}Input struct {
{{if $operation.Request.Params.Properties | len -}}
{{$data := $operation.Request.Params}}
{{if $operation.Request.Query.Properties | len -}}
{{$data := $operation.Request.Query}}
{{template "RenderProperties" passThrough $data `location:"params"`}}
{{- end -}}
}
func (v *{{$opID}}Input) Validate() error {
{{template "ValidateCustomizedType" $operation.Request.Params}}
{{template "ValidateCustomizedType" $operation.Request.Query}}
{{template "ValidateCustomizedType" $operation.Request.Headers}}
{{template "ValidateCustomizedType" $operation.Request.Elements}}
@ -137,9 +137,11 @@
type {{$opID}}Output struct {
Message *string `json:"message" name:"message"`
{{- if $operation.Response.Elements.Properties | len -}}
{{$data := $operation.Response.Elements}}
{{template "RenderProperties" passThrough $data `location:"elements"`}}
{{- range $k, $reponse := $operation.Responses -}}
{{- if $reponse.Elements.Properties | len -}}
{{$data := $reponse.Elements}}
{{template "RenderProperties" passThrough $data `location:"elements"` $operation.Name}}
{{- end -}}
{{- end -}}
}
{{end}}