...
1
9
10 package openapi
11
12 type Metadata struct {
13 Name string `json:"name"`
14
15 Version string `json:"version"`
16
17 DisplayName string `json:"displayName"`
18
19 Description string `json:"description"`
20
21 Tags string `json:"tags"`
22
23 Architectures string `json:"architectures"`
24
25 Icon string `json:"icon"`
26
27 GlobalMemoryLimit string `json:"globalMemoryLimit"`
28
29 ProjectType string `json:"projectType"`
30
31 Language string `json:"language"`
32
33 Website string `json:"website"`
34
35 Provider string `json:"provider"`
36
37 SupportUrl string `json:"supportUrl"`
38 }
39
40
41 func AssertMetadataRequired(obj Metadata) error {
42 elements := map[string]interface{}{
43 "name": obj.Name,
44 "version": obj.Version,
45 "displayName": obj.DisplayName,
46 "description": obj.Description,
47 "tags": obj.Tags,
48 "architectures": obj.Architectures,
49 "icon": obj.Icon,
50 "globalMemoryLimit": obj.GlobalMemoryLimit,
51 "projectType": obj.ProjectType,
52 "language": obj.Language,
53 "website": obj.Website,
54 "provider": obj.Provider,
55 "supportUrl": obj.SupportUrl,
56 }
57 for name, el := range elements {
58 if isZero := IsZeroValue(el); isZero {
59 return &RequiredError{Field: name}
60 }
61 }
62
63 return nil
64 }
65
66
67
68 func AssertRecurseMetadataRequired(objSlice interface{}) error {
69 return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
70 aMetadata, ok := obj.(Metadata)
71 if !ok {
72 return ErrTypeAssertionError
73 }
74 return AssertMetadataRequired(aMetadata)
75 })
76 }
77
View as plain text