diff --git a/engines/dfc_provider/app/services/quantitative_value_builder.rb b/engines/dfc_provider/app/services/quantitative_value_builder.rb index 3de24eb6ea..b3328713e3 100644 --- a/engines/dfc_provider/app/services/quantitative_value_builder.rb +++ b/engines/dfc_provider/app/services/quantitative_value_builder.rb @@ -110,7 +110,7 @@ class QuantitativeValueBuilder < DfcBuilder else # Labels may be provided one day: # https://github.com/datafoodconsortium/connector-ruby/issues/18 - label = unit.semanticId.split("#").last || "items" + label = unit.try(:semanticId)&.split("#")&.last || "items" ["items", label, 1] end end diff --git a/engines/dfc_provider/spec/requests/supplied_products_spec.rb b/engines/dfc_provider/spec/requests/supplied_products_spec.rb index e3dde17838..c4d9ef1d6e 100644 --- a/engines/dfc_provider/spec/requests/supplied_products_spec.rb +++ b/engines/dfc_provider/spec/requests/supplied_products_spec.rb @@ -32,6 +32,9 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc-v1.7/swagger.yaml 'dfc-b': "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#", 'dfc-m': "http://static.datafoodconsortium.org/data/measures.rdf#", 'dfc-pt': "http://static.datafoodconsortium.org/data/productTypes.rdf#", + 'dfc-b:hasUnit': { + '@type': "@id" + }, }, '@id': "http://test.host/api/dfc-v1.7/enterprises/6201/supplied_products/0", '@type': "dfc-b:SuppliedProduct", diff --git a/swagger/dfc-v1.7/swagger.yaml b/swagger/dfc-v1.7/swagger.yaml index 8ef4ceba5d..431be36edb 100644 --- a/swagger/dfc-v1.7/swagger.yaml +++ b/swagger/dfc-v1.7/swagger.yaml @@ -330,7 +330,7 @@ paths: dfc-b:hasType: http://static.datafoodconsortium.org/data/productTypes.rdf#non-local-vegetable dfc-b:hasQuantity: "@type": dfc-b:QuantitativeValue - dfc-b:hasUnit: dfc-m:Piece + dfc-b:hasUnit: dfc-m:Gram dfc-b:value: 3.0 dfc-b:alcoholPercentage: 0.0 dfc-b:lifetime: '' @@ -345,6 +345,8 @@ paths: dfc-b: http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl# dfc-m: http://static.datafoodconsortium.org/data/measures.rdf# dfc-pt: http://static.datafoodconsortium.org/data/productTypes.rdf# + dfc-b:hasUnit: + "@type": "@id" "@id": http://test.host/api/dfc-v1.7/enterprises/6201/supplied_products/0 "@type": dfc-b:SuppliedProduct dfc-b:name: Apple