Use IsJsonOnly

This commit is contained in:
Andrew Nester 2023-06-20 11:19:03 +02:00
parent 74a2f40f54
commit 724cd8237f
No known key found for this signature in database
GPG Key ID: 12BC628A44B7DA57
1 changed files with 2 additions and 2 deletions

View File

@ -58,7 +58,7 @@ func init() {
{{if .Request}}// TODO: short flags
{{.CamelName}}Cmd.Flags().Var(&{{.CamelName}}Json, "json", `either inline JSON string or @path/to/file.json with request body`)
{{$method := .}}
{{ if not .JsonOnly }}
{{ if not .IsJsonOnly }}
{{range .Request.Fields -}}
{{- if not .Required -}}
{{if .Entity.IsObject }}// TODO: complex arg: {{.Name}}
@ -135,7 +135,7 @@ var {{.CamelName}}Cmd = &cobra.Command{
}
{{- end -}}
{{$method := .}}
{{- if and .Request.IsAllRequiredFieldsPrimitive (not .JsonOnly) -}}
{{- if and .Request.IsAllRequiredFieldsPrimitive (not .IsJsonOnly) -}}
{{- range $arg, $field := .Request.RequiredFields}}
{{if not $field.Entity.IsString -}}
_, err = fmt.Sscan(args[{{$arg}}], &{{$method.CamelName}}Req.{{$field.PascalName}})