Skip to content

Commit

Permalink
Merge pull request #56 from HDRUK/GAT-4972
Browse files Browse the repository at this point in the history
update regex in hydration and revsions in GWDM
  • Loading branch information
BSnelling authored Sep 2, 2024
2 parents b8ff848 + b515134 commit fb822b4
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
5 changes: 3 additions & 2 deletions docs/GWDM/2.0.form.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"https://api.service.nhs.uk/health-research-data-catalogue/datasetrevisions/841f7da2-b018-41f6-b4ae-2e0aadab6561"
],
"is_list": false,
"is_optional": false,
"is_optional": true,
"types": {
"title": "Url",
"format": "uri",
Expand Down Expand Up @@ -1593,5 +1593,6 @@
},
"location": "omics.platform"
}
]
],
"url_regex": "(https?:\\/\\/)?([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}(:\\d+)?(\\/[^\\s]*)?$"
}
6 changes: 3 additions & 3 deletions docs/GWDM/2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ Examples:

Some url with a reference to the record of a previous version of this dataset

| title | guidance | is_list | required | type |
|:-------------|:-----------|:----------|:-----------|:--------------------------------------------------------------------------------------------|
| revision url | | False | True | ["Url[{'anyOf': [{'format': 'uri', 'minLength': 1, 'type': 'string'}, {'type': 'null'}]}]"] |
| title | guidance | is_list | required | type |
|:-------------|:-----------|:----------|:-----------|:----------------------------------------------------------------------------------------------------|
| revision url | | False | True | ["Url[{'anyOf': [{'format': 'uri', 'minLength': 1, 'type': 'string'}, {'type': 'null'}]}]", 'null'] |

Examples:

Expand Down
5 changes: 3 additions & 2 deletions docs/GWDM/2.0.structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@
"https://api.service.nhs.uk/health-research-data-catalogue/datasetrevisions/841f7da2-b018-41f6-b4ae-2e0aadab6561"
],
"type": [
"Url[{'anyOf': [{'format': 'uri', 'minLength': 1, 'type': 'string'}, {'type': 'null'}]}]"
"Url[{'anyOf': [{'format': 'uri', 'minLength': 1, 'type': 'string'}, {'type': 'null'}]}]",
"null"
],
"is_list": false,
"is_optional": false,
"is_optional": true,
"subItems": []
}
]
Expand Down
3 changes: 2 additions & 1 deletion docs/HDRUK/3.0.0.form.json
Original file line number Diff line number Diff line change
Expand Up @@ -1841,5 +1841,6 @@
},
"location": "omics.platform"
}
]
],
"url_regex": "^\\s*((https?:\\/\\/)*([a-zA-Z0-9-]+\\.?)+[a-zA-Z]{2,}(:\\d+)?(\\/[^\\s]*)?(\n)?)+$"
}
5 changes: 4 additions & 1 deletion hdr_schemata/models/GWDM/2.0/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1368,9 +1368,12 @@
"type": "string"
},
"url": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/Url"
},
{
"type": "null"
}
],
"description": "Some url with a reference to the record of a previous version of this dataset",
Expand Down
3 changes: 2 additions & 1 deletion hdr_schemata/models/GWDM/v2_0/Revision.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pydantic import AnyUrl, BaseModel, EmailStr, Field, constr
from hdr_schemata.definitions.HDRUK import *
from typing import Optional

from .annotations import annotations

Expand All @@ -13,7 +14,7 @@ class Revision(BaseModel):
**an.version.__dict__,
)

url: Url = Field(
url: Optional[Url] = Field(
...,
**an.url.__dict__,
)
1 change: 1 addition & 0 deletions hdr_schemata/utils/create_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def remove_types(data):

form = {}
form["schema_fields"] = []
form["url_regex"] = "^\s*((https?:\/\/)*([a-zA-Z0-9-]+\.?)+[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?(\n)?)+$"
form_structure(structure, form)
with open(f"{path}/{name}.form.json", "w") as f:
json.dump(form, f, indent=6)
Expand Down

0 comments on commit fb822b4

Please sign in to comment.