Skip to content

Resolving ref in definition section

Abhishek Kumar (SLB) requested to merge schema-ref-issue-slb into master

$ref value inside definitions section is not getting resolved correctly.

Before Fix Ref value at /definitions/projectedPosition/elevationFromMsl is not resolved correctly

{
   "$schema":"http://json-schema.org/draft-07/schema#",
   "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json",
   "$comment":"This is a test schema",
   "type":"object",
   "title":"My schema - Changed",
   "definitions":{
      "projectedPosition":{
         "type":"object",
         "properties":{
            "elevationFromMsl":{
               "title":"Elevation from MSL",
               "description":"Elevation from Mean Seal Level, downwards negative. The unit definition is found via 'elevationFromMsl.unitKey' in 'frameOfReference.units' dictionary.",
               "$ref":"osdu:wks:valueWithUnit:1.0.0"
            }
         }
      },
      "osdu:wks:valueWithUnit:1.0.0":{
         "type":"object"
      }
   },
   "properties":{
      "AddressLine1":{
         "type":"string",
         "$comment":"This is a mandatory attribute"
      },
      "AddressLine2":{
         "type":"string"
      },
      "City":{
         "type":"string"
      }
   }
}

After Fix

{
   "$schema":"http://json-schema.org/draft-07/schema#",
   "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json",
   "$comment":"This is a test schema",
   "type":"object",
   "title":"My schema - Changed",
   "definitions":{
      "projectedPosition":{
         "type":"object",
         "properties":{
            "elevationFromMsl":{
               "title":"Elevation from MSL",
               "description":"Elevation from Mean Seal Level, downwards negative. The unit definition is found via 'elevationFromMsl.unitKey' in 'frameOfReference.units' dictionary.",
               "$ref":"#/definitions/osdu:wks:valueWithUnit:1.0.0"
            }
         }
      },
      "osdu:wks:valueWithUnit:1.0.0":{
         "type":"object"
      }
   },
   "properties":{
      "AddressLine1":{
         "type":"string",
         "$comment":"This is a mandatory attribute"
      },
      "AddressLine2":{
         "type":"string"
      },
      "City":{
         "type":"string"
      }
   }
}
Edited by Abhishek Kumar (SLB)

Merge request reports

Loading