forked from go-chassis/go-chassis
/
struct.go
executable file
·141 lines (126 loc) · 4.57 KB
/
struct.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package registry
// MicroService struct having full info about micro-service
type MicroService struct {
ServiceID string
AppID string
ServiceName string
Version string
Environment string
Status string
Level string
Schemas []string
Metadata map[string]string
Framework *Framework
RegisterBy string
}
// Framework struct having info about micro-service version, name
type Framework struct {
Name string
Version string
}
// MicroServiceInstance struct having full info about micro-service instance
type MicroServiceInstance struct {
InstanceID string
HostName string
ServiceID string
DefaultProtocol string
DefaultEndpoint string
Status string
Environment string
EndpointsMap map[string]string
Metadata map[string]string
DataCenterInfo *DataCenterInfo
Stage string
}
// MicroServiceDependency is for to represent dependencies of micro-service
type MicroServiceDependency struct {
Consumer *MicroService
Providers []*MicroService
}
// DataCenterInfo represents micro-service data center info
type DataCenterInfo struct {
Name string
Region string
AvailableZone string
}
// SourceInfo source info
type SourceInfo struct {
Name string
Tags map[string]string
}
// Schema to represents schema info
type Schema struct {
Schema string `json:"schema"`
}
// SchemaContent represents schema contents info
type SchemaContent struct {
Swagger string `yaml:"swagger"`
Info map[string]string `yaml:"info"`
BasePath string `yaml:"basePath"`
Produces []string `yaml:"produces"`
Paths map[string]map[string]MethodInfo `yaml:"paths"`
Definition map[string]Definition `yaml:"definitions"`
}
// SchemaContents represents array of schema contents
type SchemaContents struct {
Schemas []*SchemaContent
}
// MethodInfo represents method info
type MethodInfo struct {
OperationID string `yaml:"operationId"`
Parameters []Parameter `yaml:"parameters"`
Response map[string]Response `yaml:"responses"`
}
// Parameter represents schema parameters
type Parameter struct {
Name string `yaml:"name"`
In string `yaml:"in"`
Required bool `yaml:"required"`
Type string `yaml:"type"`
Format string `yaml:"format"`
Items Item `yaml:"items"`
ColFormat string `yaml:"collectionFormat"`
Schema SchemaValue `yaml:"schema"`
}
// SchemaValue represents additional info of schema
type SchemaValue struct {
Reference string `yaml:"$ref"`
Format string `yaml:"format"`
Title string `yaml:"title"`
Description string `yaml:"description"`
Default string `yaml:"default"`
MultipleOf int `yaml:"multipleOf"`
ExclusiveMaximum int `yaml:"exclusiveMaximum"`
Minimum int `yaml:"minimum"`
ExclusiveMinimum int `yaml:"exclusiveMinimum"`
MaxLength int `yaml:"maxLength"`
MinLength int `yaml:"minLength"`
Pattern int `yaml:"pattern"`
MaxItems int `yaml:"maxItems"`
MinItems int `yaml:"minItems"`
UniqueItems bool `yaml:"uniqueItems"`
MaxProperties int `yaml:"maxProperties"`
MinProperties int `yaml:"minProperties"`
Required bool `yaml:"required"`
Enum []interface{} `yaml:"enum"`
Type string `yaml:"type"`
Items Item `yaml:"items"`
Properties map[string]interface{} `yaml:"properties"`
AdditionalProperties map[string]string `yaml:"additionalProperties"`
}
// Item represents type of the schema
type Item struct {
Type string `yaml:"type"`
XML map[string]interface{} `yaml:"xml"`
}
// Response represents schema response
type Response struct {
Description string `yaml:"description"`
Schema map[string]string `yaml:"schema"`
}
// Definition struct represents types, xjavaclass, properities
type Definition struct {
Types string `yaml:"type"`
XJavaClass string `yaml:"x-java-class"`
Properties map[string]interface{} `yaml:"properties"`
}