Skip to content

A public place to field feedback and releases of metadata schema for Tezos storage artifacts.

Notifications You must be signed in to change notification settings

oxheadalpha/tezos-snapshot-metadata-schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 

Repository files navigation

tezos-schema

A public place to field feedback and releases of metadata schema for Tezos storage artifacts.

We're using GitHub discussions to field questions/improvements/suggestions for this repo. Feel free to open a discussion and we'll turn it into an issue, and eventually- a release.

Validate your own metadata

bash

https://github.com/python-jsonschema/check-jsonschema

pip install check-jsonschema
check-jsonschema --schemafile schema.json input.json
ok -- validation done

python

https://pypi.org/project/jsonschema/

from jsonschema import validate
import json

f = open('schema.json')
schema = json.load(f)

f = open('input.json')
input = json.load(f)

validate(input,schema=schema)
# returns nothing if valid

go

https://github.com/xeipuuv/gojsonschema

package main

import (
    "fmt"
    "github.com/xeipuuv/gojsonschema"
)

func main() {

    schemaLoader := gojsonschema.NewReferenceLoader("file:///home/me/schema.json")
    documentLoader := gojsonschema.NewReferenceLoader("file:///home/me/document.json")

    result, err := gojsonschema.Validate(schemaLoader, documentLoader)
    if err != nil {
        panic(err.Error())
    }

    if result.Valid() {
        fmt.Printf("The document is valid\n")
    } else {
        fmt.Printf("The document is not valid. see errors :\n")
        for _, desc := range result.Errors() {
            fmt.Printf("- %s\n", desc)
        }
    }
}
// Returns "The document is valid" if successful

npm/*script

https://www.npmjs.com/package/jsonschema

npm install jsonschema
var validate = require('jsonschema').validate;
var schema = JSON.parse(fs.readFileSync('schema.json'))
var input = JSON.parse(fs.readFileSync('input.json'))
validate(input,schema)

About

A public place to field feedback and releases of metadata schema for Tezos storage artifacts.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published