isamplesorg / isamples_inabox

Provides functionality intermediate to a collection and central
0 stars 1 forks source link

Validation of json from Export service #377

Open smrgeoinfo opened 2 months ago

smrgeoinfo commented 2 months ago

response from url "https://central.isample.xyz/isamples_central/export/create?q=id:IGSN\:NHB000TLJ&export_format=jsonl" -H "Authorization: Bearer

Response doesn't validate with iSamplesSchemaCore1.0.json:

{
    "sample_identifier": "IGSN:NHB000TLJ",
    "label": "NMNH 125875-00 (MIN)",
    "description": null,
    "source_collection": "SESAR",
    "has_specimen_category": ["Other solid object"],
    "has_material_category": ["Mineral"],
    "has_context_category": ["Earth interior"],
    "informal_classification": ["Not Provided"],
    "keywords": ["Individual Sample"],
    "produced_by": {
        "@id": "",
        "label": "",
        "responsibility": ["Adam Mansur,,Sample Owner"],
        "description": "",
        "result_time": "2015-05-02T11:21:17Z",
        "has_feature_of_interest": "",
        "sampling_site": {
            "description": "Matched to Tsumeb (3352593) in GeoNames based on township and country. Assigned a 5 km error radius around the city.",
            "label": "",
            "place_name": [
                "Otjikoto",
                "Tsumeb"
            ],
            "sample_location": {},
            "elevation": "",
            "latitude": -19.23,
            "longitude": 17.72
        }
    },
    "registrant": {
        "name": ["Adam Mansur"]
    },
    "sampling_purpose": null,
    "curation": {
        "label": "",
        "description": "",
        "access_constraints": "",
        "curation_location": "",
        "responsibility": ""
    },
    "related_resource": null,
    "authorized_by": null,
    "complies_with": null
}

ERRORS:

/description: expected type: String, found: Null

/has_material_category/0: expected type: JSONObject, found: String

/has_context_category/0: expected type: JSONObject, found: String

/keywords/0: expected type: JSONObject, found: String

/produced_by/@id: extraneous key [@id] is not permitted

/produced_by/responsibility/0: expected type: JSONObject, found: String

/produced_by/result_time: [2015-05-02T11:21:17Z] is not a valid date. Expected [yyyy-MM-dd]

/produced_by/sampling_site/elevation: extraneous key [elevation] is not permitted

/produced_by/sampling_site/latitude: extraneous key [latitude] is not permitted

/produced_by/sampling_site/longitude: extraneous key [longitude] is not permitted

/registrant/name: expected type: String, found: JSONArray

/sampling_purpose: expected type: String, found: Null

/curation/access_constraints: expected type: JSONArray, found: String

/curation/responsibility: expected type: JSONArray, found: String

/related_resource: expected type: JSONArray, found: Null

/complies_with: expected type: JSONArray, found: Null

Valid record:

{
    "sample_identifier": "IGSN:NHB000TLJ",
    "label": "NMNH 125875-00 (MIN)",
    "description": "",
    "source_collection": "SESAR",
    "has_sample_object_type": [{"label":"Other solid object"}],
    "has_material_category": [{"label":"Mineral"}],
    "has_context_category": [{"label":"Earth interior"}],
    "keywords": [{"keyword":"Individual Sample"}],
    "produced_by": {
        "identifier": "",
        "label": "",
        "responsibility": [{"name":"Adam Mansur","role":"Sample Owner"}],
        "description": "",
        "result_time": "2015-05-02",
        "has_feature_of_interest": "",
        "sampling_site": {
            "description": "Matched to Tsumeb (3352593) in GeoNames based on township and country. Assigned a 5 km error radius around the city.",
            "label": "",
            "place_name": [
                "Otjikoto",
                "Tsumeb"
            ],
            "sample_location": {
            "elevation": "",
            "latitude": -19.23,
            "longitude": 17.72 }
        }
    },
    "registrant": {
        "name": "Adam Mansur"
    },
    "sampling_purpose": "",
    "curation": {
        "label": "",
        "description": "",
        "access_constraints": [],
        "curation_location": "",
        "responsibility": []
    },
    "related_resource": [],
    "authorized_by": null,
    "complies_with": []
}

Could leave out the empty elements:

{
    "sample_identifier": "IGSN:NHB000TLJ",
    "label": "NMNH 125875-00 (MIN)",
    "source_collection": "SESAR",
    "has_sample_object_type": [{"label":"Other solid object"}],
    "has_material_category": [{"label":"Mineral"}],
    "has_context_category": [{"label":"Earth interior"}],
    "keywords": [{"keyword":"Individual Sample"}],
    "produced_by": {
        "responsibility": [{"name":"Adam Mansur","role":"Sample Owner"}],
        "result_time": "2015-05-02",
        "sampling_site": {
            "description": "Matched to Tsumeb (3352593) in GeoNames based on township and country. Assigned a 5 km error radius around the city.",
            "place_name": [
                "Otjikoto",
                "Tsumeb"
            ],
            "sample_location": {
            "latitude": -19.23,
            "longitude": 17.72 }
        }
    },
    "registrant": {
        "name": "Adam Mansur"
    }
}

Of course since its registered by smithsonian Natural History museum, could infer "curation": { "curation_location": "Smithsonian Institution, Museum of Natural History", },

dannymandel commented 1 month ago

Leaving out the empty ones will definitely be an easy fix. I'll certainly do that. Some of them may be a bit trickier, but I'll get the validation hooked into our unit tests the same way we did for the output from the thing API.

dannymandel commented 1 month ago

These fixes were made in https://github.com/isamplesorg/isamples_inabox/pull/382 but aren't deployed yet.