Skip to content

Validate multiple YAML document structure using JSON Schema with jsonschema #927

Closed
@sujaypatil96

Description

@sujaypatil96

Is there something wrong I'm doing when I try to validate the following multi YAML object file using its corresponding JSON Schema with the jsonschema validation tool?

File to be validated: instance.yaml

authors: GOA-UniProt curators
id: GO_REF:0000029
is_obsolete: true
year: 2007
layout: goref
title: OBSOLETE Gene Ontology annotation based on information extracted from curated
  UniProtKB entries
comments:
- Active 2001-2007.
- Method by which GO terms were manually assigned to UniProt KnowledgeBase accessions,
  using either a NAS or TAS evidence code, by applying information extracted from
  the corresponding publicly-available, manually curated UniProtKB entry. Such GO
  annotations were submitted by the GOA-UniProt group from 2001, but this annotation
  practice was discontinued in 2007.
---
authors: GO ontology editors
id: GO_REF:0000078
year: 2013
layout: goref
title: Representation for the transport or vesicle-mediated transport of a chemical
  from and/or to a cell component as biological process in the Gene Ontology
comments:
- 'We have created a standard template for classes describing the transport or vesicle-mediated
  transport of a chemical entity (ChEBI) from and/or to a cellular component as a
  biological process. The underlying equivalence axiom templates are "GO:0006810 and
  ''transports or maintains localization of'' some X [ and ''has_target_start_location''
  some F] [ and ''has_target_end_location'' some T]" (transport) and "GO:0016192 and
  ''transports or maintains localization of'' some X [ and ''has_target_start_location''
  some F] [ and ''has_target_end_location'' some T]" (vesicle-mediated transport),
  where F and T are cellular components and X is a chemical entity (CHEBI:24431).
  The approach to combine GO and ChEBI has been described in the following publication:
  PMID:23895341.'

JSON Schema validation file: project.schema.json

{
    "$schema": "http://json-schema.org/draft-07/schema",
    "$id": "https://example.com/gorefs.schema.json",
    "title": "JSON Schema for validating gorefs.yaml",
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "authors": {
                "type": "string",
                "description": ""
            },
            "id": {
                "type": "string",
                "pattern": "GO_REF:\\d{7}",
                "description": ""
            },
            "is_obsolete": {
                "type":"boolean",
                "description": ""
            },
            "year": {
                "type": "integer",
                "description": ""
            },
            "layout": {
                "type": "string",
                "description": ""
            },
            "title": {
                "type": "string",
                "description": ""
            },
            "comments": {
                "type": "array",
                "items": {
                    "type": "string"
                },
                "description": ""
            }
        }
    }
}

Here is my log:

> jsonschema -i instance.yaml project.schema.json
Failed to parse 'instance.yaml': Expecting value: line 1 column 1 (char 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions