-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathrequest_response_mapping.go
More file actions
37 lines (28 loc) · 1.01 KB
/
request_response_mapping.go
File metadata and controls
37 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"context"
"github.com/swaggest/usecase"
)
func reqRespMapping() usecase.Interactor {
type inputPort struct {
Val1 string `description:"Simple scalar value with sample validation." required:"true" minLength:"3"`
Val2 int `description:"Simple scalar value with sample validation." required:"true" minimum:"3"`
}
type outputPort struct {
Val1 string `json:"-" description:"Simple scalar value with sample validation." required:"true" minLength:"3"`
Val2 int `json:"-" description:"Simple scalar value with sample validation." required:"true" minimum:"3"`
}
u := usecase.NewIOI(new(inputPort), new(outputPort), func(ctx context.Context, input, output any) (err error) {
var (
in = input.(*inputPort)
out = output.(*outputPort)
)
out.Val1 = in.Val1
out.Val2 = in.Val2
return nil
})
u.SetTitle("Request Response Mapping")
u.SetName("reqRespMapping")
u.SetDescription("This use case has transport concerns fully decoupled with external req/resp mapping.")
return u
}