-
Notifications
You must be signed in to change notification settings - Fork 67
/
model_grpc_response.go
49 lines (42 loc) 路 1.29 KB
/
model_grpc_response.go
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
38
39
40
41
42
43
44
45
46
47
48
49
/*
* TraceTest
*
* OpenAPI definition for TraceTest endpoint and resources
*
* API version: 0.2.1
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
type GrpcResponse struct {
StatusCode int32 `json:"statusCode"`
Metadata []GrpcHeader `json:"metadata,omitempty"`
Body string `json:"body,omitempty"`
}
// AssertGrpcResponseRequired checks if the required fields are not zero-ed
func AssertGrpcResponseRequired(obj GrpcResponse) error {
elements := map[string]interface{}{
"statusCode": obj.StatusCode,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {
return &RequiredError{Field: name}
}
}
for _, el := range obj.Metadata {
if err := AssertGrpcHeaderRequired(el); err != nil {
return err
}
}
return nil
}
// AssertRecurseGrpcResponseRequired recursively checks if required fields are not zero-ed in a nested slice.
// Accepts only nested slice of GrpcResponse (e.g. [][]GrpcResponse), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseGrpcResponseRequired(objSlice interface{}) error {
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
aGrpcResponse, ok := obj.(GrpcResponse)
if !ok {
return ErrTypeAssertionError
}
return AssertGrpcResponseRequired(aGrpcResponse)
})
}