You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Fhir specification states that the "resourceType" element is a required element for a resource, but no other elements are required. When deserializing a resource using the FhirJsonParser.Parse function only the "resourceType" element is required to be present. When attempting to deserialize the same resource using the JsonSerializer.Deserialize function, an exception is thrown that states An object needs to have at least one property. This goes against the guidance in the developer guide http://hl7.org/fhir/r4/overview-dev.html since the "data" or subsequent elements are Optional
Each instance of a resource consists of:
resourceType (line 2) - Required: FHIR defines many different types of resources. See the full index
id (line 3) - The id of this resource. Always present when a resource is exchanged, except during the create operation (below)
extension (lines 12 - 17) - Optional: Extensions defined by the extensibility framework
data (lines 18 - 43) - Optional: data elements - a different set, defined for each type of resource
To Reproduce
The following code will reproduce the behavior:
string str = "{\"resourceType\": \"Parameters\"}";
// This will deserialize fine
var works = new FhirJsonParser().Parse<Parameters>(str);
JsonSerializerOptions options = new JsonSerializerOptions().ForFhir(typeof(Parameters).Assembly);
// This will throw an exception
var throws = JsonSerializer.Deserialize<Parameters>(str, options);
Expected behavior
The JsonSerializer.Deserialize function should not throw an exception and instead should return a deserialized resource with no populated elements.
Describe the bug
The Fhir specification states that the "resourceType" element is a required element for a resource, but no other elements are required. When deserializing a resource using the
FhirJsonParser.Parse
function only the "resourceType" element is required to be present. When attempting to deserialize the same resource using theJsonSerializer.Deserialize
function, an exception is thrown that statesAn object needs to have at least one property.
This goes against the guidance in the developer guide http://hl7.org/fhir/r4/overview-dev.html since the "data" or subsequent elements are OptionalTo Reproduce
The following code will reproduce the behavior:
Expected behavior
The
JsonSerializer.Deserialize
function should not throw an exception and instead should return a deserialized resource with no populated elements.Screenshots
Version used:
R4
Additional context
The
ERR.OBJECTS_CANNOT_BE_EMPTY
error should not be added to thestate.Errors
collection https://github.com/FirelyTeam/firely-net-common/blob/develop/src/Hl7.Fhir.Support.Poco/Serialization/FhirJsonPocoDeserializer.cs#L285The text was updated successfully, but these errors were encountered: