fix example string generation for types with isBasicLatin pattern
[netconf.git] / restconf / sal-rest-docgen / src / test / resources / yang / string-types.yang
1 module string-types {
2     yang-version 1;
3     namespace "urn:ietf:params:xml:ns:yang:test:string:types";
4     prefix "str-tp";
5
6     typedef DisplayString {
7         type string {
8             length "0..255";
9             pattern "((\p{IsBasicLatin}{0,255}))";
10         }
11     }
12
13     typedef PhysAddress {
14         type string {
15             pattern "((([0-9A-Fa-f]{2}){1}):)";
16         }
17     }
18
19     typedef MacAddress {
20         type string {
21             length "6";
22             pattern "((([0-9A-Fa-f]{2}){1}):)";
23         }
24     }
25
26     typedef DateAndTime {
27         type string {
28             length "8|11";
29             pattern "((0|[1-9](([0-9]){0,4}))-(0|[1-9](([0-9]){0,2}))-(0|[1-9](([0-9]){0,2})),(0|[1-9](([0-9]){0,2})):(0|[1-9](([0-9]){0,2})):(0|[1-9](([0-9]){0,2})).(0|[1-9](([0-9]){0,2})),((\p{IsBasicLatin}{1})(0|[1-9](([0-9]){0,2})):(0|[1-9](([0-9]){0,2})))?)";
30         }
31     }
32
33     typedef Arrows {
34         type string {
35             length "10";
36             pattern "((\p{IsArrows}{5,255}))";
37         }
38     }
39
40     typedef Thai {
41         type string {
42             length "10";
43             pattern "((\p{IsThai}{8,255}))";
44         }
45     }
46
47     typedef BraillePatterns {
48         type string {
49             length "10";
50             pattern "((\p{IsBraillePatterns}{4,255}))";
51         }
52     }
53
54     typedef MathematicalOperators {
55         type string {
56             length "10";
57             pattern "((\p{IsMathematicalOperators}{4,255}))";
58         }
59     }
60
61     container test {
62         description "Tests various combinations of regex expressions found in snmp yang models,
63                      which are causing problems because of isBasicLatin expression.
64
65                      According to https://unicode.org/charts/PDF/U0000.pdf basic latin characters are in range
66                      0x00-0x7F ([\x00-\xFF] or [\u0000-\u00FF]). This means it should be safe to replace isBasicLatin
67                      in regex expressions for characters in this range.";
68
69         leaf display-string {
70                 type DisplayString;
71             }
72         leaf phys-address {
73                 type PhysAddress;
74             }
75         leaf mac-address {
76             type MacAddress;
77         }
78         leaf date-and-time {
79             type DateAndTime;
80         }
81         leaf arrows {
82             type Arrows;
83         }
84         leaf thai {
85             type Thai;
86         }
87         leaf braille-patterns {
88             type BraillePatterns;
89         }
90         leaf mathematical-operators {
91             type MathematicalOperators;
92         }
93     }
94 }