Skip to content

Commit 1d58d65

Browse files
NRL-518 Revert contentType regex to simple version
1 parent e6d10c6 commit 1d58d65

File tree

9 files changed

+10
-38
lines changed

9 files changed

+10
-38
lines changed

api/consumer/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ components:
11011101
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
11021102
contentType:
11031103
type: string
1104-
pattern: "^(application|audio|image|message|model|multipart|text|video)/[a-zA-Z0-9!#$&^_+.-]+(;[a-zA-Z0-9!#$&^_+.-]+=[a-zA-Z0-9!#$&^_+.-]+)*$"
1104+
pattern: "[^\\s]+(\\s[^\\s]+)*"
11051105
description: Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
11061106
language:
11071107
type: string

api/producer/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ components:
16661666
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
16671667
contentType:
16681668
type: string
1669-
pattern: "^(application|audio|image|message|model|multipart|text|video)/[a-zA-Z0-9!#$&^_+.-]+(;[a-zA-Z0-9!#$&^_+.-]+=[a-zA-Z0-9!#$&^_+.-]+)*$"
1669+
pattern: "[^\\s]+(\\s[^\\s]+)*"
16701670
description: Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
16711671
language:
16721672
type: string

layer/nrlf/consumer/fhir/r4/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: swagger.yaml
3-
# timestamp: 2024-11-26T15:05:35+00:00
3+
# timestamp: 2024-12-05T16:54:49+00:00
44

55
from __future__ import annotations
66

@@ -136,7 +136,7 @@ class Attachment(BaseModel):
136136
str,
137137
Field(
138138
description="Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.",
139-
pattern="^(application|audio|image|message|model|multipart|text|video)/[a-zA-Z0-9!#$&^_+.-]+(;[a-zA-Z0-9!#$&^_+.-]+=[a-zA-Z0-9!#$&^_+.-]+)*$",
139+
pattern="[^\\s]+(\\s[^\\s]+)*",
140140
),
141141
]
142142
language: Annotated[

layer/nrlf/core/tests/test_pydantic_errors.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,3 @@ def test_validate_content_missing_content_type():
6161
"diagnostics": "Failed to parse DocumentReference resource (content.0.attachment.contentType: Field required)",
6262
"expression": ["content.0.attachment.contentType"],
6363
}
64-
65-
66-
def test_validate_content_invalid_content_type():
67-
validator = DocumentReferenceValidator()
68-
document_ref_data = load_document_reference_json("Y05868-736253002-Valid")
69-
70-
document_ref_data["content"][0]["attachment"]["contentType"] = "invalid/type"
71-
72-
with pytest.raises(ParseError) as error:
73-
validator.validate(document_ref_data)
74-
75-
exc = error.value
76-
assert len(exc.issues) == 1
77-
assert exc.issues[0].model_dump(exclude_none=True) == {
78-
"severity": "error",
79-
"code": "invalid",
80-
"details": {
81-
"coding": [
82-
{
83-
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
84-
"code": "INVALID_RESOURCE",
85-
"display": "Invalid validation of resource",
86-
}
87-
]
88-
},
89-
"diagnostics": "Failed to parse DocumentReference resource (content.0.attachment.contentType: String should match pattern '^(application|audio|image|message|model|multipart|text|video)/[a-zA-Z0-9!#$&^_+.-]+(;[a-zA-Z0-9!#$&^_+.-]+=[a-zA-Z0-9!#$&^_+.-]+)*$')",
90-
"expression": ["content.0.attachment.contentType"],
91-
}

layer/nrlf/producer/fhir/r4/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: swagger.yaml
3-
# timestamp: 2024-11-26T15:05:33+00:00
3+
# timestamp: 2024-12-05T16:54:46+00:00
44

55
from __future__ import annotations
66

@@ -136,7 +136,7 @@ class Attachment(BaseModel):
136136
str,
137137
Field(
138138
description="Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.",
139-
pattern="^(application|audio|image|message|model|multipart|text|video)/[a-zA-Z0-9!#$&^_+.-]+(;[a-zA-Z0-9!#$&^_+.-]+=[a-zA-Z0-9!#$&^_+.-]+)*$",
139+
pattern="[^\\s]+(\\s[^\\s]+)*",
140140
),
141141
]
142142
language: Annotated[

layer/nrlf/producer/fhir/r4/strict_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: swagger.yaml
3-
# timestamp: 2024-11-26T15:05:34+00:00
3+
# timestamp: 2024-12-05T16:54:48+00:00
44

55
from __future__ import annotations
66

tests/features/producer/createDocumentReference-failure.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ Feature: Producer - createDocumentReference - Failure Scenarios
725725
}
726726
]
727727
},
728-
"diagnostics": "Request body could not be parsed (content.0.attachment.contentType: String should match pattern '^(application|audio|image|message|model|multipart|text|video)/[a-zA-Z0-9!#$&^_+.-]+(;[a-zA-Z0-9!#$&^_+.-]+=[a-zA-Z0-9!#$&^_+.-]+)*$')",
728+
"diagnostics": "Request body could not be parsed (content.0.attachment.contentType: String should match pattern '[^\\s]+(\\s[^\\s]+)*')",
729729
"expression": [
730730
"content.0.attachment.contentType"
731731
]

tests/features/producer/updateDocumentReference-failure.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Feature: Producer - updateDocumentReference - Failure Scenarios
144144
}
145145
]
146146
},
147-
"diagnostics": "Request body could not be parsed (content.0.attachment.contentType: String should match pattern '^(application|audio|image|message|model|multipart|text|video)/[a-zA-Z0-9!#$&^_+.-]+(;[a-zA-Z0-9!#$&^_+.-]+=[a-zA-Z0-9!#$&^_+.-]+)*$')",
147+
"diagnostics": "Request body could not be parsed (content.0.attachment.contentType: String should match pattern '[^\\s]+(\\s[^\\s]+)*')",
148148
"expression": [
149149
"content.0.attachment.contentType"
150150
]

tests/features/producer/upsertDocumentReference-failure.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ Feature: Producer - upsertDocumentReference - Failure Scenarios
306306
}
307307
]
308308
},
309-
"diagnostics": "Request body could not be parsed (content.0.attachment.contentType: String should match pattern '^(application|audio|image|message|model|multipart|text|video)/[a-zA-Z0-9!#$&^_+.-]+(;[a-zA-Z0-9!#$&^_+.-]+=[a-zA-Z0-9!#$&^_+.-]+)*$')",
309+
"diagnostics": "Request body could not be parsed (content.0.attachment.contentType: String should match pattern '[^\\s]+(\\s[^\\s]+)*')",
310310
"expression": [
311311
"content.0.attachment.contentType"
312312
]

0 commit comments

Comments
 (0)