Merge pull request #63 from runzexia/update-template
Update template to fit snips change
This commit is contained in:
commit
a8cf7b7324
6
Makefile
6
Makefile
|
@ -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
|
||||
|
|
|
@ -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}}
|
||||
|
|
Loading…
Reference in New Issue