Skip to content

Commit

Permalink
Merge pull request #61 from norc-heal/fix/additionalProperties
Browse files Browse the repository at this point in the history
Fix: additional properties to false for all levels
  • Loading branch information
AJuehneNIH authored Jun 21, 2024
2 parents 147b977 + c9689a4 commit 0262e08
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSIONS.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"slmd":"1.0.0",
"vlmd":"0.3.1"
"vlmd":"0.3.2"
}
7 changes: 7 additions & 0 deletions variable-level-metadata-schema/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ def flatten_properties(properties, parentkey="", sep=".",itemsep="\[\d+\]"):
return properties_flattened

def flatten_schema(schema):
"""
Flatten a schema of type object with properties.
If a regular expression indicating a list index exists, puts this
under `patternProperties`
"""
schema_flattened = dict(schema)
if "properties" in schema:
properties = schema_flattened.pop("properties")
Expand Down
2 changes: 1 addition & 1 deletion variable-level-metadata-schema/docs/csvtemplate-fields.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HEAL Variable Level Metadata Fields

_version 0.3.1_
_version 0.3.2_

<!-- Below annotation is specific for folks filling out the csv template
and so is put here rather than in the actual schema annotations.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Variable Level Metadata (Data Dictionaries)

_version 0.3.1_
_version 0.3.2_

This schema defines the variable level metadata for one data dictionary for a given study.Note a given study can have multiple data dictionaries.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"8"
]
},
"encodings": {
"enumLabels": {
"1": "White",
"2": "Black or African American",
"3": "American Indian or Alaska Native",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"version": "0.3.1",
"version": "0.3.2",
"title": "HEAL Variable Level Metadata Fields",
"description": "\n\n!!! note \"Highly encouraged\"\n\n - Only `name` and `description` properties are required. \n - For categorical variables, `constraints.enum` and `enumLabels` (where applicable) properties are highly encouraged. \n - For studies using HEAL or other common data elements (CDEs), `standardsMappings` information is highly encouraged.\n - `type` and `format` properties may be particularly useful for some variable types (e.g. date-like variables)\n",
"type": "object",
"required": [
"name",
"description"
],
"additionalProperties": false,
"properties": {
"schemaVersion": {
"type": "string",
Expand Down
4 changes: 3 additions & 1 deletion variable-level-metadata-schema/schemas/data-dictionary.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.3.1",
"version": "0.3.2",
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "vlmd",
"title": "Variable Level Metadata (Data Dictionaries)",
Expand All @@ -9,6 +9,7 @@
"title",
"fields"
],
"additionalProperties": false,
"properties": {
"title": {
"type": "string"
Expand Down Expand Up @@ -92,6 +93,7 @@
"name",
"description"
],
"additionalProperties": false,
"properties": {
"schemaVersion": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type: object
required:
- title
- fields
additionalProperties: false
properties:
title:
type: string
Expand Down Expand Up @@ -47,3 +48,4 @@ propertyNames:
- missingValues
- primaryKey
- foreignKeys

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type: object
required:
- name
- description
additionalProperties: false
properties:
schemaVersion:
$ref: "#/_definitions/schemaVersion"
Expand Down
2 changes: 1 addition & 1 deletion variable-level-metadata-schema/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_valid_json_data_dictionaries():
jsonreports = []
for filepath in jsons:
report = to_summary(filepath)
assert report["valid"],f"# this example is invalid but is intended to be valid:\n\n {str(filepath)}\n\n{report_summary}"
assert report["valid"],f"# this example is invalid but is intended to be valid:\n\n {json.dumps(report['errors'],indent=2)}"


def test_invalid_csv_data_dictionaries():
Expand Down

0 comments on commit 0262e08

Please sign in to comment.