@@ -556,8 +556,9 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(ctx context.Context,
556556 g .w (f (g .Endpoint ))
557557 } else {
558558 var (
559- pathGrow strings.Builder
560- pathContent strings.Builder
559+ requiredArgsValidation strings.Builder
560+ pathGrow strings.Builder
561+ pathContent strings.Builder
561562 )
562563
563564 pathGrow .WriteString (` path.Grow(` )
@@ -599,15 +600,18 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(ctx context.Context,
599600 pathContent .WriteString (` path.WriteString("/")` + "\n " )
600601 switch a .Type {
601602 case "int" :
603+ requiredArgsValidation .WriteString (`if r.` + p + ` == nil { return nil, errors.New("` + a .Name + ` is required and cannot be nil") }` + "\n " )
602604 pathGrow .WriteString (`len(strconv.Itoa(*r.` + p + `)) + ` )
603605 pathContent .WriteString (` path.WriteString(strconv.Itoa(*r.` + p + `))` + "\n " )
604606 case "string" :
605607 pathGrow .WriteString (`len(r.` + p + `) + ` )
606608 pathContent .WriteString (` path.WriteString(r.` + p + `)` + "\n " )
607609 case "list" :
610+ requiredArgsValidation .WriteString (`if len(r.` + p + `) == 0 { return nil, errors.New("` + a .Name + ` is required and cannot be nil or empty") }` + "\n " )
608611 pathGrow .WriteString (`len(strings.Join(r.` + p + `, ",")) + ` )
609612 pathContent .WriteString (` path.WriteString(strings.Join(r.` + p + `, ","))` + "\n " )
610613 case "long" :
614+ requiredArgsValidation .WriteString (`if r.` + p + ` == nil { return nil, errors.New("` + a .Name + ` is required and cannot be nil") }` + "\n " )
611615 pathGrow .WriteString (`len(strconv.Itoa(*r.` + p + `)) + ` )
612616 pathContent .WriteString (` path.WriteString(strconv.Itoa(*r.` + p + `))` + "\n " )
613617 default :
@@ -686,6 +690,7 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(ctx context.Context,
686690
687691 // Write out the content
688692 pathGrow .WriteString (`)` )
693+ g .w (requiredArgsValidation .String () + "\n " )
689694 g .w (strings .Replace (pathGrow .String (), " + )" , ")" , 1 ) + "\n " )
690695 g .w (pathContent .String () + "\n " )
691696 }
0 commit comments