Skip to content

Commit

Permalink
FI-1223: Support the validator /version returning a JSON (#448)
Browse files Browse the repository at this point in the history
* FI-1223: support the validator /version returning a JSON

* FI-1223: add rescue in case of JSON parse error

* rubocop fix
  • Loading branch information
dehall authored Aug 8, 2023
1 parent 5e43193 commit cabc507
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/onc_certification_g10_test_kit/configuration_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ def validator_url

def validator_version_message
response = Faraday.get "#{validator_url}/version"
version = response.body

if response.body.starts_with? '{'
version_json = JSON.parse(response.body)
version = version_json['inferno-framework/fhir-validator-wrapper']
else
version = response.body
end

if version == EXPECTED_VALIDATOR_VERSION
[{
Expand All @@ -35,6 +41,11 @@ def validator_version_message
message: "Expected FHIR validator version `#{EXPECTED_VALIDATOR_VERSION}`, but found `#{version}`"
}]
end
rescue JSON::ParserError => e
[{
type: 'error',
message: "Unable to parse Validator version '`#{response.body}`'. Parser error: `#{e.message}`"
}]
rescue StandardError => e
[{
type: 'error',
Expand Down

0 comments on commit cabc507

Please sign in to comment.