@@ -569,8 +569,9 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(ctx context.Context,
569569 g .w (f (g .Endpoint ))
570570 } else {
571571 var (
572- pathGrow strings.Builder
573- pathContent strings.Builder
572+ requiredArgsValidation strings.Builder
573+ pathGrow strings.Builder
574+ pathContent strings.Builder
574575 )
575576
576577 pathGrow .WriteString (` path.Grow(` )
@@ -623,15 +624,18 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(ctx context.Context,
623624 pathContent .WriteString (` path.WriteString("/")` + "\n " )
624625 switch a .Type {
625626 case "int" :
627+ requiredArgsValidation .WriteString (`if r.` + p + ` == nil { return nil, errors.New("` + a .Name + ` is required and cannot be nil") }` + "\n " )
626628 pathGrow .WriteString (`len(strconv.Itoa(*r.` + p + `)) + ` )
627629 pathContent .WriteString (` path.WriteString(strconv.Itoa(*r.` + p + `))` + "\n " )
628630 case "string" :
629631 pathGrow .WriteString (`len(r.` + p + `) + ` )
630632 pathContent .WriteString (` path.WriteString(r.` + p + `)` + "\n " )
631633 case "list" :
634+ requiredArgsValidation .WriteString (`if len(r.` + p + `) == 0 { return nil, errors.New("` + a .Name + ` is required and cannot be nil or empty") }` + "\n " )
632635 pathGrow .WriteString (`len(strings.Join(r.` + p + `, ",")) + ` )
633636 pathContent .WriteString (` path.WriteString(strings.Join(r.` + p + `, ","))` + "\n " )
634637 case "long" :
638+ requiredArgsValidation .WriteString (`if r.` + p + ` == nil { return nil, errors.New("` + a .Name + ` is required and cannot be nil") }` + "\n " )
635639 pathGrow .WriteString (`len(strconv.Itoa(*r.` + p + `)) + ` )
636640 pathContent .WriteString (` path.WriteString(strconv.Itoa(*r.` + p + `))` + "\n " )
637641 default :
@@ -710,6 +714,7 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(ctx context.Context,
710714
711715 // Write out the content
712716 pathGrow .WriteString (`)` )
717+ g .w (requiredArgsValidation .String () + "\n " )
713718 g .w (strings .Replace (pathGrow .String (), " + )" , ")" , 1 ) + "\n " )
714719 g .w (pathContent .String () + "\n " )
715720 }
0 commit comments