fix example string generation for types with isBasicLatin pattern
[netconf.git] / restconf / sal-rest-docgen / src / test / resources / yang / string-types.yang
diff --git a/restconf/sal-rest-docgen/src/test/resources/yang/string-types.yang b/restconf/sal-rest-docgen/src/test/resources/yang/string-types.yang
new file mode 100644 (file)
index 0000000..3283b1d
--- /dev/null
@@ -0,0 +1,94 @@
+module string-types {
+    yang-version 1;
+    namespace "urn:ietf:params:xml:ns:yang:test:string:types";
+    prefix "str-tp";
+
+    typedef DisplayString {
+        type string {
+            length "0..255";
+            pattern "((\p{IsBasicLatin}{0,255}))";
+        }
+    }
+
+    typedef PhysAddress {
+        type string {
+            pattern "((([0-9A-Fa-f]{2}){1}):)";
+        }
+    }
+
+    typedef MacAddress {
+        type string {
+            length "6";
+            pattern "((([0-9A-Fa-f]{2}){1}):)";
+        }
+    }
+
+    typedef DateAndTime {
+        type string {
+            length "8|11";
+            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})))?)";
+        }
+    }
+
+    typedef Arrows {
+        type string {
+            length "10";
+            pattern "((\p{IsArrows}{5,255}))";
+        }
+    }
+
+    typedef Thai {
+        type string {
+            length "10";
+            pattern "((\p{IsThai}{8,255}))";
+        }
+    }
+
+    typedef BraillePatterns {
+        type string {
+            length "10";
+            pattern "((\p{IsBraillePatterns}{4,255}))";
+        }
+    }
+
+    typedef MathematicalOperators {
+        type string {
+            length "10";
+            pattern "((\p{IsMathematicalOperators}{4,255}))";
+        }
+    }
+
+    container test {
+        description "Tests various combinations of regex expressions found in snmp yang models,
+                     which are causing problems because of isBasicLatin expression.
+
+                     According to https://unicode.org/charts/PDF/U0000.pdf basic latin characters are in range
+                     0x00-0x7F ([\x00-\xFF] or [\u0000-\u00FF]). This means it should be safe to replace isBasicLatin
+                     in regex expressions for characters in this range.";
+
+        leaf display-string {
+                type DisplayString;
+            }
+        leaf phys-address {
+                type PhysAddress;
+            }
+        leaf mac-address {
+            type MacAddress;
+        }
+        leaf date-and-time {
+            type DateAndTime;
+        }
+        leaf arrows {
+            type Arrows;
+        }
+        leaf thai {
+            type Thai;
+        }
+        leaf braille-patterns {
+            type BraillePatterns;
+        }
+        leaf mathematical-operators {
+            type MathematicalOperators;
+        }
+    }
+}
\ No newline at end of file