-
Notifications
You must be signed in to change notification settings - Fork 1
/
openrpc_types.go
137 lines (119 loc) · 5.94 KB
/
openrpc_types.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
package openrpc
const (
// https://json-schema.org/understanding-json-schema/reference/type.html
stringSchema string = `{ "type": "string", "pattern": "(.*)" }`
boolSchema string = `{ "type": "boolean", "pattern": "(true|false)" }`
// using [0-9] instead of \d because json returns an error
integerSchema string = `{ "type": "integer", "pattern": "(^[0-9]*$)" }`
numberSchema string = `{ "type": "number", "pattern": "^([0-9]*\.[0-9]+)$|^([0-9]*)$" }`
anySchema string = `{}`
nullSchema string = `{ "type": "null" }`
)
type DocumentSpec1 struct {
OpenRPC/* required */ string `json:"openrpc"`
Info/* required */ *Info `json:"info"`
Servers []*Server `json:"servers,omitempty"`
Methods/* required */ []*Method `json:"methods"`
Components *Components `json:"components,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
//Objects *ObjectMap `json:"-"`
}
type Info struct {
Title/* required */ string `json:"title"`
Description string `json:"description,omitempty"`
TermsOfService string `json:"termsOfService,omitempty"`
Contact Contact `json:"contact,omitempty"`
License *License `json:"license,omitempty"`
Version/* required */ string `json:"version"`
}
type Server struct {
Name/* required */ string `json:"name"`
URL/* required */ string `json:"url"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Variables map[string]*ServerVariable `json:"variables,omitempty"`
}
type ServerVariable struct {
Enum []string `json:"enum,omitempty"`
Default/* required */ string `json:"default"`
Description string `json:"description,omitempty"`
}
type Method struct {
Name/* required */ string `json:"name"`
Tags []Tag `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
Params/* required */ []*ContentDescriptor `json:"params"`
Result/* required */ *ContentDescriptor `json:"result"`
Deprecated bool `json:"deprecated,omitempty"`
Servers []Server `json:"servers,omitempty"`
Errors []Error `json:"errors,omitempty"`
Links []Link `json:"links,omitempty"`
ParamStructure string `json:"paramStructure,omitempty"`
Examples []*ExamplePairing `json:"examples,omitempty"`
}
type Components struct {
ContentDescriptors *SchemaRegistry `json:"contentDescriptors,omitempty"`
Schemas *SchemaRegistry `json:"schemas,omitempty"`
Examples *SchemaRegistry `json:"examples,omitempty"`
Links *SchemaRegistry `json:"links,omitempty"`
Errors *SchemaRegistry `json:"errors,omitempty"`
ExamplePairingObjects *SchemaRegistry `json:"examplePairingObjects,omitempty"`
Tags *SchemaRegistry `json:"tags,omitempty"`
}
type ContentDescriptor struct {
Name/* required */ string `json:"name"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Schema/* required */ Pointer `json:"schema"`
}
type ExternalDocs struct {
Description string `json:"description,omitempty"`
URL/* required */ string `json:"url"`
}
// Misc
type Contact struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
type License struct {
Name/* required*/ string `json:"name"`
URL string `json:"url,omitempty"`
}
type Tag struct {
Name/* required */ string `json:"name"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
}
type Error struct {
Code/* required */ int `json:"code"`
Message/* required */ string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
type Link struct {
Name/* required */ string `json:"name"`
Description string `json:"description,omitempty"`
Summary string `json:"summary,omitempty"`
Method string `json:"method,omitempty"`
Params map[string]interface{} `json:"params,omitempty"`
Server *Server `json:"server,omitempty"`
}
type Example struct {
Name string `json:"name,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Value interface{} `json:"value,omitempty"`
ExternalValue string `json:"externalValue,omitempty"`
}
type ExamplePairing struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Summary string `json:"summary,omitempty"`
Params []*Example `json:"params,omitempty"`
Result *Example `json:"result,omitempty"`
}