Added json validation and schema

This commit is contained in:
Hugo Bernier 2022-02-12 20:33:06 -05:00 committed by GitHub
parent 11e43dc403
commit f76cff16d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 208 additions and 1 deletions

View File

@ -27,7 +27,11 @@ jobs:
path: './'
- run: |
jq -s '[.[][]]' samples/**/assets/sample.json > samples.json
- name: Validate JSON
uses: docker://orrosenblatt/validate-json-action:latest
env:
INPUT_SCHEMA: /metadata-schema.json
INPUT_JSONS: /samples.json
- name: Commit updated file
uses: EndBug/add-and-commit@v6
with:

203
metadata-schema.json Normal file
View File

@ -0,0 +1,203 @@
{
"$id": "https://developer.microsoft.com/en-us/json-schemas/pnp/samples/v1.0/metadata-schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
},
"source": {
"type": "string"
},
"title": {
"type": "string"
},
"url": {
"type": "string"
},
"creationDateTime": {
"type": "string"
},
"updateDateTime": {
"type": "string"
},
"shortDescription": {
"type": "string"
},
"longDescription": {
"type": "array",
"items": {
"type": "string"
}
},
"products": {
"type": "array",
"items": {
"type": "string"
}
},
"categories": {
"type": "array",
"items": {
"type": "string"
}
},
"metadata": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"value"
]
}
},
"thumbnails": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"image",
"video",
"slideshow"
]
},
"order": {
"type": "integer"
},
"alt": {
"type": "string"
}
},
"if": {
"properties": {
"type": {
"const": "slideshow"
}
}
},
"then": {
"properties": {
"slides": {
"type": "array",
"items": {
"type": "object",
"properties": {
"url": {
"type": "string"
},
"order": {
"type": "integer"
},
"alt": {
"type": "string"
}
},
"required": [
"url",
"order",
"alt"
]
}
}
},
"required": [
"slides"
]
},
"else": {
"properties": {
"url": {
"type": "string"
}
},
"required": [
"url"
]
},
"required": [
"type",
"order",
"alt"
]
}
]
},
"authors": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"gitHubAccount": {
"type": "string",
"pattern": "^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$"
},
"company": {
"type": "string"
},
"pictureUrl": {
"type": "string"
}
},
"required": [
"gitHubAccount"
]
}
]
},
"references": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"url": {
"type": "string"
}
},
"required": [
"name",
"url"
]
}
]
}
},
"required": [
"name",
"source",
"title",
"shortDescription",
"products",
"metadata",
"thumbnails",
"authors",
"creationDateTime",
"updateDateTime"
]
}
}