isamplesorg / isamples_inabox

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

Core JSON returned by API doesn't validate against JSON schema #370

Open smrgeoinfo opened 2 months ago

smrgeoinfo commented 2 months ago

Using JSON schema iSamples (github-- isamplesorg/metadata/src/schemas/iSamplesSchemaCore1.0.json

get metadata records in core schema via the API, e.g. https://central.isample.xyz/isamples_central/thing/ark%3A%2F65665%2F309fc4ed5-cbc9-4821-918a-1ff0aa92d0dd?format=core

Load the JSON in Oxygen, and run validator against JSON schema (I tried on records from all 4 authorities). Errors reported:

smrgeoinfo commented 1 month ago

generalize dates to allow YYYY, YYYY-MM, YYYY-MM-DD, YYYY-MM-DDThh-mm etc.... Update schema. Generate issue

dannymandel commented 1 month ago

This is done. Will be fixed next time we push to central. The change we made to the schema (which we now validate against our unit tests) was this:

                "result_time": {
                    "description": "Date on which the sample was collected.",
                    "anyOf": [
                        {
                            "format": "date"
                        },
                        {
                            "format": "date-time"
                        }
                    ],

                    "type": "string"
                },
smrgeoinfo commented 1 month ago

Have to update the LinkML/YAML schema as well to keep in sync with the JSON. I was going to allow all the various formats (YYYY, YYYY-MM, YYYY-MM-DD, YYYY-MM-DDThh-mm), but then went out of town before I could figure out how to do it in the LinkML

smrgeoinfo commented 4 weeks ago

I'd suggest adding some regex patterns to allow YYYY and YYYY-MM: "anyOf": [ { "format": "date", "description": "YYYY-MM-DD" }, { "format": "date-time", "description": "YYYY:MM::DDThh:mm:ss.sTZD" }, { "pattern": "^(?:[1]?[0-9]{3}|20[0-2][0-9])$", "description": "gets YYYY" }, { "pattern": "^(?:[1]?[0-9]{3}|20[0-2][0-9])-(?:0[1-9]|1[0-2])$", "description": "gets YYYY-MM" } ],

see https://github.com/isamplesorg/isamples_inabox/issues/389