Stream: dotnet
Topic: Unable to validate against the specification
Kirt Noel (Dec 05 2019 at 13:33):
I am working on a project that requires the use of the API v0.95.0. The NuGet package Hl7.Fhir.Specification.STU3 is installed.
I am struggling to pass tests of the most simple of validations.
// Arrange // .. code to create Organization resource var zipSource = ZipSource.CreateValidationSource(); var validationSettings = new ValidationSettings() { ResourceResolver = zipSource, GenerateSnapshot = true }; var validator = new Validator(validationSettings); // Act var outcome = validator.Validate(organizationResource); // Assert outcome.Success.Should().BeTrue();
I encounter the following issue:
{"Overall result: FAILURE (1 errors and 0 warnings) [ERROR] Unable to resolve reference to profile 'http://hl7.org/fhir/StructureDefinition/Organization' (at Organization)"}
I anticipated the Validator would have, by default, used the specification.zip file included in the Hl7.Fhir.Specification.STU3 package.
Any help to identify what I'm omitting or doing incorrectly is appreciated.
Kirt Noel (Dec 05 2019 at 23:37):
This obstacle disappears when i create a new console project. I believe I have something else going on in my code.
Brian Postlethwaite (Dec 05 2019 at 23:42):
Looks like your code is right, maybe the specification.zip isn't in the runtime folder where it runs and therefore isn't able to use it.
Kirt Noel (Dec 07 2019 at 12:10):
Thanks for your input Brian.
I have corrected this. The obstacle to validating turned out to be the presence of conflicting NuGet packages for Newtonsoft.Json and System.ValueTuple; the Fhir packages depended on different versions than the code base I was working with.
These conflicts presented as warnings rather than build errors. I made the error of discounting the importance of these warnings.
When I took the time to address these conflicts, the validation worked just fine.
Last updated: Apr 12 2022 at 19:14 UTC