Schema is getting created even if invalid def ref is passed in payload
When there is an internal $ref
value in schema service, for example, “$ref”: “#/definitions/example”, but the “example” is missing in the definitions
section we should throw an exception, because this should be invalid input. Currently, we allow schema to be created even if the definition for an internal reference is missing.
State after the fix - this should not be allowed, because 'person' is missing in the definitions
section:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"x-os-lifecycle-state": "published",
"description": "The entity well.",
"title": "Well",
"type": "object",
"definitions": { },
"properties": {
"person": {
"description": "Information for person",
"title": "Information for person",
"$ref": "#/definitions/person"
},
"locationOriginalCRS": {
"description": "The well's original location as AnyCrsFeatureCollection - a structure similar to but distinct from GeoJSON.",
"title": "Original CRS Location",
"$ref": "os:wks:anyCrsFeatureCollection.1.0"
},
"locationWGS84": {
"description": "The well's location as GeoJSON FeatureCollection.",
"title": "WGS84 Location",
"$ref": "https://geojson.org/schema/FeatureCollection.json",
"example": {
"features": [
{
"geometry": {
"coordinates": [
-92.11569999999999,
29.8823,
153.4779442519685
],
"type": "Point"
},
"type": "Feature",
"properties": {
"name": "Newton 2-31"
}
}
],
"type": "FeatureCollection"
}
}
}
}