Repository: INCATools/dead_simple_owl_design_patterns (language: python)

Issue:
var names should be restricted to valid variable names 
spec: alphanumeric +  '_', first character must not be number.   In regex [a-zA-Z_][a-zA-Z_0-9]*

 - [ ] Add to spec - ideally as JSON schema, of not as part of description
 - [ ] Add check to validator - only rqd if can't formally add to schema




Discussion / hints:
Update - I think not possible to add to formal spec with the current (json schema v4 validator) as this part is *only* enforced by convention! 

![image](https://user-images.githubusercontent.com/112839/104045468-84ee6800-51d6-11eb-8720-e07017a7d796.png)


 However, we could if we switch to JSON schema version 6+ or  http://json-schema.org/understanding-json-schema/reference/object.html#property-names.  The validator lib we use now supports this

https://python-jsonschema.readthedocs.io/en/latest/validate/#jsonschema.Draft6Validator



Fix patch:
diff --git a/spec/DOSDP_schema_full.yaml b/spec/DOSDP_schema_full.yaml
index 906040f..d3bcd3a 100644
--- a/spec/DOSDP_schema_full.yaml
+++ b/spec/DOSDP_schema_full.yaml
@@ -1,4 +1,4 @@
-$schema: "http://json-schema.org/draft-04/schema#"
+$schema: "http://json-schema.org/draft-07/schema#"
 #id: 'https://github.com/dosumis/dead_simple_owl_design_patterns/edit/master/spec/DOSDP_spec.json' # Use Purl?
 title: DOSDP
 type: object
@@ -290,12 +290,16 @@ properties:
 
   vars:
     type: object
+    propertyNames: 
+       pattern: "^[A-Za-z_][A-Za-z0-9_]*$"
     description: >
      A dictionary of variables ranging over OWL classes.  
      Key = variable name, value = variable range as manchester syntax string.
      
   list_vars:
     type: object
+    propertyNames: 
+       pattern: "^[A-Za-z_][A-Za-z0-9_]*$"
     description: >
      A dictionary of variables refering to lists of owl classes.
      Key = variable name, value = variable range of items in list specified as a valid OWL
@@ -303,12 +307,17 @@ properties:
   
   data_vars:
     type: object
+    propertyNames: 
+       pattern: "^[A-Za-z_][A-Za-z0-9_]*$"
     description: >
      A dictionary of variables ranging over OWL data-types.
      Key = variable name, value = variable range specified as a valid OWL
      data-type.
      
   data_list_vars:
+    type: object
+    propertyNames: 
+       pattern: "^[A-Za-z_][A-Za-z0-9_]*$"
     description: >
         A dictionary of variables rrefering to lists of some specified OWL data-types.
         Key = variable name, value = variable range of all items in list, 


Test patch:
diff --git a/src/simple_pattern_tester.py b/src/simple_pattern_tester.py
index a9c194a..d86531e 100755
--- a/src/simple_pattern_tester.py
+++ b/src/simple_pattern_tester.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-from jsonschema import Draft4Validator
+from jsonschema import Draft7Validator
 import sys
 import glob
 import re