forked from open-rpc/meta-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.rs
470 lines (469 loc) · 15.4 KB
/
index.rs
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
extern crate serde_json;
#[derive(Serialize, Deserialize)]
pub enum Openrpc {
#[serde(rename = "1.2.6")]
26,
#[serde(rename = "1.2.5")]
25,
#[serde(rename = "1.2.4")]
24,
#[serde(rename = "1.2.3")]
23,
#[serde(rename = "1.2.2")]
22,
#[serde(rename = "1.2.1")]
21,
#[serde(rename = "1.2.0")]
20,
#[serde(rename = "1.1.12")]
112,
#[serde(rename = "1.1.11")]
111,
#[serde(rename = "1.1.10")]
110,
#[serde(rename = "1.1.9")]
19,
#[serde(rename = "1.1.8")]
18,
#[serde(rename = "1.1.7")]
17,
#[serde(rename = "1.1.6")]
16,
#[serde(rename = "1.1.5")]
15,
#[serde(rename = "1.1.4")]
14,
#[serde(rename = "1.1.3")]
13,
#[serde(rename = "1.1.2")]
12,
#[serde(rename = "1.1.1")]
11,
#[serde(rename = "1.1.0")]
10,
#[serde(rename = "1.0.0")]
00,
#[serde(rename = "1.0.0-rc1")]
00Rc1,
#[serde(rename = "1.0.0-rc0")]
00Rc0,
}
pub type InfoObjectProperties = String;
pub type InfoObjectDescription = String;
pub type InfoObjectTermsOfService = String;
pub type InfoObjectVersion = String;
pub type ContactObjectName = String;
pub type ContactObjectEmail = String;
pub type ContactObjectUrl = String;
pub type SpecificationExtension = serde_json::Value;
#[derive(Serialize, Deserialize)]
pub struct ContactObject {
pub(crate) name: Option<ContactObjectName>,
pub(crate) email: Option<ContactObjectEmail>,
pub(crate) url: Option<ContactObjectUrl>,
}
pub type LicenseObjectName = String;
pub type LicenseObjectUrl = String;
#[derive(Serialize, Deserialize)]
pub struct LicenseObject {
pub(crate) name: Option<LicenseObjectName>,
pub(crate) url: Option<LicenseObjectUrl>,
}
#[derive(Serialize, Deserialize)]
pub struct InfoObject {
pub(crate) title: InfoObjectProperties,
pub(crate) description: Option<InfoObjectDescription>,
pub(crate) termsOfService: Option<InfoObjectTermsOfService>,
pub(crate) version: InfoObjectVersion,
pub(crate) contact: Option<ContactObject>,
pub(crate) license: Option<LicenseObject>,
}
pub type ExternalDocumentationObjectDescription = String;
pub type ExternalDocumentationObjectUrl = String;
/// ExternalDocumentationObject
///
/// information about external documentation
///
#[derive(Serialize, Deserialize)]
pub struct ExternalDocumentationObject {
pub(crate) description: Option<ExternalDocumentationObjectDescription>,
pub(crate) url: ExternalDocumentationObjectUrl,
}
pub type ServerObjectUrl = String;
pub type ServerObjectName = String;
pub type ServerObjectDescription = String;
pub type ServerObjectSummary = String;
pub type ServerObjectVariableDefault = String;
pub type ServerObjectVariableDescription = String;
pub type ServerObjectVariableEnumItem = String;
pub type ServerObjectVariableEnum = Vec<ServerObjectVariableEnumItem>;
#[derive(Serialize, Deserialize)]
pub struct ServerObjectVariable {
pub(crate) default: ServerObjectVariableDefault,
pub(crate) description: Option<ServerObjectVariableDescription>,
pub(crate) enum: Option<ServerObjectVariableEnum>,
}
pub type ServerObjectVariables = HashMap<String, Option<serde_json::Value>>;
#[derive(Serialize, Deserialize)]
pub struct ServerObject {
pub(crate) url: ServerObjectUrl,
pub(crate) name: Option<ServerObjectName>,
pub(crate) description: Option<ServerObjectDescription>,
pub(crate) summary: Option<ServerObjectSummary>,
pub(crate) variables: Option<ServerObjectVariables>,
}
pub type Servers = Vec<ServerObject>;
/// MethodObjectName
///
/// The cannonical name for the method. The name MUST be unique within the methods array.
///
pub type MethodObjectName = String;
/// MethodObjectDescription
///
/// A verbose explanation of the method behavior. GitHub Flavored Markdown syntax MAY be used for rich text representation.
///
pub type MethodObjectDescription = String;
/// MethodObjectSummary
///
/// A short summary of what the method does.
///
pub type MethodObjectSummary = String;
pub type TagObjectName = String;
pub type TagObjectDescription = String;
#[derive(Serialize, Deserialize)]
pub struct TagObject {
pub(crate) name: TagObjectName,
pub(crate) description: Option<TagObjectDescription>,
pub(crate) externalDocs: Option<ExternalDocumentationObject>,
}
pub type $Ref = String;
#[derive(Serialize, Deserialize)]
pub struct ReferenceObject {
pub(crate) $ref: $Ref,
}
#[derive(Serialize, Deserialize)]
pub enum TagOrReference {
TagObject,
ReferenceObject
}
pub type MethodObjectTags = Vec<TagOrReference>;
/// MethodObjectParamStructure
///
/// Format the server expects the params. Defaults to 'either'.
///
/// # Default
///
/// either
///
#[derive(Serialize, Deserialize)]
pub enum MethodObjectParamStructure {
#[serde(rename = "by-position")]
ByPosition,
#[serde(rename = "by-name")]
ByName,
#[serde(rename = "either")]
Either,
}
pub type ContentDescriptorObjectName = String;
pub type ContentDescriptorObjectDescription = String;
pub type ContentDescriptorObjectSummary = String;
pub type $Id = String;
pub type $Schema = String;
pub type $Comment = String;
pub type Title = String;
pub type Description = String;
type AlwaysTrue = serde_json::Value;
pub type ReadOnly = bool;
pub type Examples = Vec<AlwaysTrue>;
pub type MultipleOf = f64;
pub type Maximum = f64;
pub type ExclusiveMaximum = f64;
pub type Minimum = f64;
pub type ExclusiveMinimum = f64;
pub type NonNegativeInteger = i64;
pub type NonNegativeIntegerDefaultZero = i64;
pub type Pattern = String;
pub type SchemaArray = Vec<JSONSchema>;
#[derive(Serialize, Deserialize)]
pub enum Items {
JSONSchema,
SchemaArray
}
pub type UniqueItems = bool;
pub type StringDoaGddGA = String;
/// StringArray
///
/// # Default
///
/// []
///
pub type StringArray = Vec<StringDoaGddGA>;
/// Definitions
///
/// # Default
///
/// {}
///
pub type Definitions = HashMap<String, Option<serde_json::Value>>;
/// Properties
///
/// # Default
///
/// {}
///
pub type Properties = HashMap<String, Option<serde_json::Value>>;
/// PatternProperties
///
/// # Default
///
/// {}
///
pub type PatternProperties = HashMap<String, Option<serde_json::Value>>;
#[derive(Serialize, Deserialize)]
pub enum DependenciesSet {
JSONSchema,
StringArray
}
pub type Dependencies = HashMap<String, Option<serde_json::Value>>;
pub type Enum = Vec<AlwaysTrue>;
pub type SimpleTypes = serde_json::Value;
pub type ArrayOfSimpleTypes = Vec<SimpleTypes>;
#[derive(Serialize, Deserialize)]
pub enum Type {
SimpleTypes,
ArrayOfSimpleTypes
}
pub type Format = String;
pub type ContentMediaType = String;
pub type ContentEncoding = String;
#[derive(Serialize, Deserialize)]
pub struct JSONSchemaObject {
pub(crate) $id: Option<$Id>,
pub(crate) $schema: Option<$Schema>,
pub(crate) $ref: Option<$Ref>,
pub(crate) $comment: Option<$Comment>,
pub(crate) title: Option<Title>,
pub(crate) description: Option<Description>,
pub(crate) default: Option<AlwaysTrue>,
pub(crate) readOnly: Option<ReadOnly>,
pub(crate) examples: Option<Examples>,
pub(crate) multipleOf: Option<MultipleOf>,
pub(crate) maximum: Option<Maximum>,
pub(crate) exclusiveMaximum: Option<ExclusiveMaximum>,
pub(crate) minimum: Option<Minimum>,
pub(crate) exclusiveMinimum: Option<ExclusiveMinimum>,
pub(crate) maxLength: Option<NonNegativeInteger>,
pub(crate) minLength: Option<NonNegativeIntegerDefaultZero>,
pub(crate) pattern: Option<Pattern>,
pub(crate) additionalItems: Option<JSONSchema>,
pub(crate) items: Option<Items>,
pub(crate) maxItems: Option<NonNegativeInteger>,
pub(crate) minItems: Option<NonNegativeIntegerDefaultZero>,
pub(crate) uniqueItems: Option<UniqueItems>,
pub(crate) contains: Option<JSONSchema>,
pub(crate) maxProperties: Option<NonNegativeInteger>,
pub(crate) minProperties: Option<NonNegativeIntegerDefaultZero>,
pub(crate) required: Option<StringArray>,
pub(crate) additionalProperties: Option<JSONSchema>,
pub(crate) definitions: Option<Definitions>,
pub(crate) properties: Option<Properties>,
pub(crate) patternProperties: Option<PatternProperties>,
pub(crate) dependencies: Option<Dependencies>,
pub(crate) propertyNames: Option<JSONSchema>,
pub(crate) const: Option<AlwaysTrue>,
pub(crate) enum: Option<Enum>,
pub(crate) type: Option<Type>,
pub(crate) format: Option<Format>,
pub(crate) contentMediaType: Option<ContentMediaType>,
pub(crate) contentEncoding: Option<ContentEncoding>,
pub(crate) if: Option<JSONSchema>,
pub(crate) then: Option<JSONSchema>,
pub(crate) else: Option<JSONSchema>,
pub(crate) allOf: Option<SchemaArray>,
pub(crate) anyOf: Option<SchemaArray>,
pub(crate) oneOf: Option<SchemaArray>,
pub(crate) not: Option<JSONSchema>,
}
/// JSONSchemaBoolean
///
/// Always valid if true. Never valid if false. Is constant.
///
pub type JSONSchemaBoolean = bool;
#[derive(Serialize, Deserialize)]
pub enum JSONSchema {
JSONSchemaObject,
JSONSchemaBoolean
}
pub type ContentDescriptorObjectRequired = bool;
pub type ContentDescriptorObjectDeprecated = bool;
#[derive(Serialize, Deserialize)]
pub struct ContentDescriptorObject {
pub(crate) name: ContentDescriptorObjectName,
pub(crate) description: Option<ContentDescriptorObjectDescription>,
pub(crate) summary: Option<ContentDescriptorObjectSummary>,
pub(crate) schema: JSONSchema,
pub(crate) required: Option<ContentDescriptorObjectRequired>,
pub(crate) deprecated: Option<ContentDescriptorObjectDeprecated>,
}
#[derive(Serialize, Deserialize)]
pub enum ContentDescriptorOrReference {
ContentDescriptorObject,
ReferenceObject
}
pub type MethodObjectParams = Vec<ContentDescriptorOrReference>;
#[derive(Serialize, Deserialize)]
pub enum MethodObjectResult {
ContentDescriptorObject,
ReferenceObject
}
/// ErrorObjectCode
///
/// A Number that indicates the error type that occurred. This MUST be an integer. The error codes from and including -32768 to -32000 are reserved for pre-defined errors. These pre-defined errors SHOULD be assumed to be returned from any JSON-RPC api.
///
pub type ErrorObjectCode = i64;
/// ErrorObjectMessage
///
/// A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.
///
pub type ErrorObjectMessage = String;
/// ErrorObjectData
///
/// A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
///
pub type ErrorObjectData = serde_json::Value;
/// ErrorObject
///
/// Defines an application level error.
///
#[derive(Serialize, Deserialize)]
pub struct ErrorObject {
pub(crate) code: ErrorObjectCode,
pub(crate) message: ErrorObjectMessage,
pub(crate) data: Option<ErrorObjectData>,
}
#[derive(Serialize, Deserialize)]
pub enum ErrorOrReference {
ErrorObject,
ReferenceObject
}
/// MethodObjectErrors
///
/// Defines an application level error.
///
pub type MethodObjectErrors = Vec<ErrorOrReference>;
pub type LinkObjectName = String;
pub type LinkObjectSummary = String;
pub type LinkObjectMethod = String;
pub type LinkObjectDescription = String;
pub type LinkObjectParams = serde_json::Value;
#[derive(Serialize, Deserialize)]
pub struct LinkObjectServer {
pub(crate) url: ServerObjectUrl,
pub(crate) name: Option<ServerObjectName>,
pub(crate) description: Option<ServerObjectDescription>,
pub(crate) summary: Option<ServerObjectSummary>,
pub(crate) variables: Option<ServerObjectVariables>,
}
#[derive(Serialize, Deserialize)]
pub struct LinkObject {
pub(crate) name: Option<LinkObjectName>,
pub(crate) summary: Option<LinkObjectSummary>,
pub(crate) method: Option<LinkObjectMethod>,
pub(crate) description: Option<LinkObjectDescription>,
pub(crate) params: Option<LinkObjectParams>,
pub(crate) server: Option<LinkObjectServer>,
}
#[derive(Serialize, Deserialize)]
pub enum LinkOrReference {
LinkObject,
ReferenceObject
}
pub type MethodObjectLinks = Vec<LinkOrReference>;
pub type ExamplePairingObjectName = String;
pub type ExamplePairingObjectDescription = String;
pub type ExampleObjectSummary = String;
pub type ExampleObjectValue = serde_json::Value;
pub type ExampleObjectDescription = String;
pub type ExampleObjectName = String;
#[derive(Serialize, Deserialize)]
pub struct ExampleObject {
pub(crate) summary: Option<ExampleObjectSummary>,
pub(crate) value: ExampleObjectValue,
pub(crate) description: Option<ExampleObjectDescription>,
pub(crate) name: ExampleObjectName,
}
#[derive(Serialize, Deserialize)]
pub enum ExampleOrReference {
ExampleObject,
ReferenceObject
}
pub type ExamplePairingObjectParams = Vec<ExampleOrReference>;
#[derive(Serialize, Deserialize)]
pub enum ExamplePairingObjectResult {
ExampleObject,
ReferenceObject
}
#[derive(Serialize, Deserialize)]
pub struct ExamplePairingObject {
pub(crate) name: ExamplePairingObjectName,
pub(crate) description: Option<ExamplePairingObjectDescription>,
pub(crate) params: ExamplePairingObjectParams,
pub(crate) result: ExamplePairingObjectResult,
}
#[derive(Serialize, Deserialize)]
pub enum ExamplePairingOrReference {
ExamplePairingObject,
ReferenceObject
}
pub type MethodObjectExamples = Vec<ExamplePairingOrReference>;
pub type MethodObjectDeprecated = bool;
#[derive(Serialize, Deserialize)]
pub struct MethodObject {
pub(crate) name: MethodObjectName,
pub(crate) description: Option<MethodObjectDescription>,
pub(crate) summary: Option<MethodObjectSummary>,
pub(crate) servers: Option<Servers>,
pub(crate) tags: Option<MethodObjectTags>,
pub(crate) paramStructure: Option<MethodObjectParamStructure>,
pub(crate) params: MethodObjectParams,
pub(crate) result: MethodObjectResult,
pub(crate) errors: Option<MethodObjectErrors>,
pub(crate) links: Option<MethodObjectLinks>,
pub(crate) examples: Option<MethodObjectExamples>,
pub(crate) deprecated: Option<MethodObjectDeprecated>,
pub(crate) externalDocs: Option<ExternalDocumentationObject>,
}
#[derive(Serialize, Deserialize)]
pub enum MethodOrReference {
MethodObject,
ReferenceObject
}
pub type Methods = Vec<MethodOrReference>;
pub type SchemaComponents = HashMap<String, Option<serde_json::Value>>;
pub type LinkComponents = HashMap<String, Option<serde_json::Value>>;
pub type ErrorComponents = HashMap<String, Option<serde_json::Value>>;
pub type ExampleComponents = HashMap<String, Option<serde_json::Value>>;
pub type ExamplePairingComponents = HashMap<String, Option<serde_json::Value>>;
pub type ContentDescriptorComponents = HashMap<String, Option<serde_json::Value>>;
pub type TagComponents = HashMap<String, Option<serde_json::Value>>;
#[derive(Serialize, Deserialize)]
pub struct Components {
pub(crate) schemas: Option<SchemaComponents>,
pub(crate) links: Option<LinkComponents>,
pub(crate) errors: Option<ErrorComponents>,
pub(crate) examples: Option<ExampleComponents>,
pub(crate) examplePairings: Option<ExamplePairingComponents>,
pub(crate) contentDescriptors: Option<ContentDescriptorComponents>,
pub(crate) tags: Option<TagComponents>,
}
#[derive(Serialize, Deserialize)]
pub struct OpenrpcDocument {
pub(crate) openrpc: Openrpc,
pub(crate) info: InfoObject,
pub(crate) externalDocs: Option<ExternalDocumentationObject>,
pub(crate) servers: Option<Servers>,
pub(crate) methods: Methods,
pub(crate) components: Option<Components>,
}