-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathyang-json-schema.yang
98 lines (95 loc) · 1.8 KB
/
yang-json-schema.yang
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
module yang-json-schema {
namespace "urn:ietf:params:xml:ns:yang:yang-json-schema";
prefix json;
yang-version 1.1;
import ietf-yang-types { prefix yang; }
import ietf-inet-types { prefix inet; }
organization
"Corenova Technologies, Inc.";
contact
"Peter K. Lee <[email protected]>";
reference
"https://json-schema.org";
/*
* Type definitions
*/
typedef json-schema-ref {
type inet:uri;
}
/*
* Groupings
*/
grouping json-datatype {
leaf type {
type enumeration {
enum string;
enum number;
enum integer;
enum boolean;
enum array;
enum file;
enum object;
}
}
leaf format {
type union {
type enumeration {
enum int32;
enum int64;
enum float;
enum double;
enum byte;
enum binary;
enum date;
enum date-time;
enum password;
}
type string;
}
}
}
grouping json-schema {
leaf $ref {
type json-schema-ref;
}
uses json:json-datatype;
leaf-list required {
type string;
// type leafref {
// path '../property/name';
// }
}
list property {
key name;
leaf name {
type yang:yang-identifier;
}
container schema {
uses json:json-schema {
when "../name";
}
}
}
container items {
when "../type = 'array'";
uses json:json-schema {
when "../type";
}
}
list allOf {
uses json:json-schema {
when "not(../type)";
}
}
list anyOf {
uses json:json-schema {
when "not(../type)";
}
}
list oneOf {
uses json:json-schema {
when "not(../property)";
}
}
}
}