api config schemas
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-02-01 18:59:17 +01:00
parent 005c903a4d
commit 590f8233ce
12 changed files with 696 additions and 13 deletions

View File

@@ -0,0 +1,187 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JSON Schema WMBasic collection configuration",
"description": "WMBasic collection linter",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "collection name, part of api path"
},
"uploadPath": {
"type": "string",
"description": "relative to config.yml, path for file uploads"
},
"meta": {
"type": "object",
"description": "meta object used for admin ui configuration",
"additionalProperties": true,
"properties": {
"label": {
"$ref": "field.json#/definitions/i18nString"
},
"muiIcon": {
"type": "string",
"description": "material ui icon name"
},
"rowIdentTpl": {
"description": "template which evaluates to short string to identify entry in pe. select boxes",
"$ref": "field.json#/definitions/evalExpressions"
},
"defaultSort": {
"type": "object",
"description": "default sort in admin ui lists",
"additionalProperties": false,
"properties": {
"field": {
"$ref": "field.json#/definitions/fieldSource"
},
"order": {
"description": "sort order",
"enum": ["ASC", "DESC"]
}
}
},
"views": {
"type": "array",
"description": "list views",
"items": {
"type": "object",
"properties": {
"mediaQuery": {
"type": "string",
"description": "css media query to select this view in ui"
}
},
"oneOf": [
{
"properties": {
"type": {
"const": "simpleList"
},
"primaryText": {
"oneOf": [
{
"$ref": "field.json#/definitions/fieldSource"
},
{
"$ref": "field.json#/definitions/evalExpressions"
}
]
},
"secondaryText": {
"oneOf": [
{
"$ref": "field.json#/definitions/fieldSource"
},
{
"$ref": "field.json#/definitions/evalExpressions"
}
]
},
"tertiaryText": {
"oneOf": [
{
"$ref": "field.json#/definitions/fieldSource"
},
{
"$ref": "field.json#/definitions/evalExpressions"
}
]
}
},
"required": ["type", "primaryText"]
},
{
"properties": {
"type": {
"const": "table"
},
"columns": {
"type": "array",
"items": {
"oneOf": [
{
"anyOf": [
{
"$ref": "field.json#/definitions/fieldSource"
},
{
"type": "object",
"properties": {
"label": {
"$ref": "field.json#/definitions/i18nString"
}
}
}
]
},
{
"allOf": [
{
"$ref": "field.json#/definitions/evalExpressions"
},
{
"properties": {
"label": {
"$ref": "field.json#/definitions/i18nString"
}
}
}
]
}
]
},
"minItems": 1
}
},
"required": ["type", "columns"]
}
],
"required": ["type"]
}
}
}
},
"projections": {
"oneOf": [
{ "$comment": "for include tag", "type": "string" },
{ "$ref": "projections.json" }
]
},
"permissions": {
"oneOf": [
{ "$comment": "for include tag", "type": "string" },
{ "$ref": "permissions.json" }
]
},
"hooks": {
"oneOf": [
{ "$comment": "for include tag", "type": "string" },
{ "$ref": "hooks.json" }
]
},
"imageFilter": {
"oneOf": [
{ "$comment": "for include tag", "type": "string" },
{ "$ref": "imageFilter.json" }
]
},
"fields": {
"type": "array",
"description": "fields of collection",
"items": {
"oneOf": [
{
"$comment": "for include tag"
},
{
"$ref": "field.json"
}
]
}
}
},
"required": ["name", "permissions"]
}

View File

@@ -0,0 +1,40 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JSON Schema WMBasic config file",
"description": "WMBasic config.yml linter",
"type": "object",
"additionalProperties": false,
"properties": {
"namespace": {
"type": "string",
"description": "suffix for mongo db database and part of api url, can be overwritten in database project settings"
},
"meta": {
"type": "object",
"description": "meta object used for admin ui configuration",
"additionalProperties": true,
"properties": {
"imageUrl": {
"type": "string",
"description": "project's teaser image url shown in admin ui"
}
}
},
"collections": {
"oneOf": [
{
"$comment": "for include tag",
"type": "string"
},
{
"type": "array",
"description": "list of collections in this project",
"items": {
"$ref": "collection.json"
}
}
]
}
},
"required": ["namespace"]
}

View File

@@ -0,0 +1,194 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JSON Schema WMBasic field configuration",
"description": "WMBasic field linter",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "name of field",
"pattern": "^[0-9a-zA-Z_]+$"
},
"type": {
"enum": [
"string",
"string[]",
"number",
"number[]",
"boolean",
"object",
"object[]",
"any"
]
},
"index": {
"type": "array",
"items": {
"enum": ["single", "unique", "text"]
}
},
"subFields": {
"type": "array",
"description": "sub fields of object",
"items": {
"$ref": "#"
}
},
"meta": {
"type": "object",
"description": "meta object of field",
"properties": {
"label": {
"$ref": "#/definitions/i18nString"
},
"helperText": {
"$ref": "#/definitions/i18nString"
},
"widget": {
"description": "ui widget",
"enum": [
"richtext",
"richText",
"html",
"checkbox",
"select",
"selectArray",
"date",
"file",
"image"
]
},
"choices": {
"type": "array",
"description": "choices to select from",
"items": {
"type": "object",
"properties": {
"name": {
"description": "name is human readable value",
"$ref": "#/definitions/i18nString"
},
"chipStyle": {
"$ref": "https://raw.githubusercontent.com/rcorp/css-schema/master/schema.json"
}
},
"oneOf": [
{
"properties": {
"id": {
"type": "number"
}
}
},
{
"properties": {
"id": {
"type": "string"
}
}
}
],
"required": ["id", "name"]
}
},
"valueMap": {
"type": "object",
"description": "map values to icons",
"patternProperties": {
".*": {
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"muiIcon": {
"type": "string"
},
"style": {
"$ref": "https://raw.githubusercontent.com/rcorp/css-schema/master/schema.json"
}
}
}
]
}
}
}
}
}
},
"required": ["name", "type"],
"definitions": {
"i18nString": {
"oneOf": [
{
"type": "object",
"patternProperties": {
"^[a-z]$": {
"type": "string"
}
}
},
{
"type": "string"
}
]
},
"evalExpressions": {
"oneOf": [
{
"type": "object",
"additionalProperties": true,
"properties": {
"twig": {
"type": "string",
"description": "twig template"
},
"projection": {
"type": "string",
"description": "query projection to use"
}
},
"required": ["twig"]
},
{
"type": "object",
"additionalProperties": true,
"properties": {
"eval": {
"type": "string",
"description": "javascript code"
},
"projection": {
"type": "string",
"description": "query projection to use"
}
},
"required": ["eval"]
}
]
},
"fieldSource": {
"oneOf": [
{
"$ref": "#/definitions/fieldPath"
},
{
"type": "object",
"properties": {
"source": {
"$ref": "#/definitions/fieldPath"
}
}
}
]
},
"fieldPath": {
"type": "string",
"description": "field, sub fields separated with dot (.)",
"pattern": "^[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)*$"
}
}
}

View File

@@ -0,0 +1,92 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JSON Schema WMBasic hooks configuration",
"description": "WMBasic hooks linter",
"type": "object",
"additionalProperties": false,
"properties": {
"get": {
"type": "object",
"description": "hooks for http GET",
"additionalProperties": false,
"properties": {
"read": {
"description": "hook before reading from database",
"$ref": "#/definitions/hookDef"
},
"return": {
"description": "hook before returning entries read from database",
"$ref": "#/definitions/hookDef"
}
}
},
"post": {
"type": "object",
"description": "hooks for http POST",
"additionalProperties": false,
"properties": {
"bind": {
"description": "hook before binding data from post request",
"$ref": "#/definitions/hookDef"
},
"create": {
"description": "hook before creating entry in database",
"$ref": "#/definitions/hookDef"
},
"return": {
"description": "hook before returning result (after database write)",
"$ref": "#/definitions/hookDef"
}
}
},
"put": {
"type": "object",
"description": "hooks for http PUT",
"additionalProperties": false,
"properties": {
"bind": {
"description": "hook before binding data from put request",
"$ref": "#/definitions/hookDef"
},
"update": {
"description": "hook before updating entry in database",
"$ref": "#/definitions/hookDef"
},
"return": {
"description": "hook before returning result (after database write)",
"$ref": "#/definitions/hookDef"
}
}
},
"delete": {
"type": "object",
"description": "hooks for http DELETE",
"additionalProperties": false,
"properties": {
"delete": {
"description": "hook before deleting entry from database",
"$ref": "#/definitions/hookDef"
},
"return": {
"description": "hook before returning result (after database write)",
"$ref": "#/definitions/hookDef"
}
}
}
},
"definitions": {
"hookDef": {
"type": "object",
"properties": {
"type": {
"const": "javascript"
},
"file": {
"type": "string",
"description": "location of javascript hook file relative to config.yml base"
}
},
"required": ["type", "file"]
}
}
}

View File

@@ -0,0 +1,63 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JSON Schema WMBasic imageFilter configuration",
"description": "WMBasic imageFilter linter",
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9_-]+$": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fit": {
"type": "boolean"
},
"fill": {
"type": "boolean"
},
"width": {
"type": "number"
},
"height": {
"type": "number"
},
"blur": {
"type": "number"
},
"brightness": {
"type": "number"
},
"contrast": {
"type": "number"
},
"gamma": {
"type": "number"
},
"saturation": {
"type": "number"
},
"sharpen": {
"type": "number"
},
"invert": {
"type": "boolean"
},
"grayscale": {
"type": "boolean"
},
"resampling": {
"enum": [
"lancos",
"nearestNeighbor",
"linear",
"catmullRom"
]
},
"quality": {
"type": "number"
}
}
}
}
}
}

View File

@@ -0,0 +1,43 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JSON Schema WMBasic permissions configuration",
"description": "WMBasic permissions linter",
"type": "object",
"additionalProperties": false,
"properties": {
"public": {
"description": "permissions for unauthorized public access",
"$ref": "#/definitions/permissionSet"
},
"user": {
"description": "permissions for authorized users (nativ wmbasic auth)",
"$ref": "#/definitions/permissionSet"
}
},
"patternProperties": {
"^token:": {
"description": "permissions for header or query token",
"$ref": "#/definitions/permissionSet"
}
},
"required": ["public", "user"],
"definitions": {
"permissionSet": {
"type": "object",
"additionalProperties": false,
"properties": {
"methods": {
"type": "object",
"description": "permissions for http methods",
"additionalProperties": false,
"properties": {
"get": { "type": "boolean" },
"post": { "type": "boolean" },
"put": { "type": "boolean" },
"delete": { "type": "boolean" }
}
}
}
}
}
}

View File

@@ -0,0 +1,22 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JSON Schema WMBasic imageFilter configuration",
"description": "WMBasic imageFilter linter",
"patternProperties": {
"^[a-zA-Z0-9_-]$": {
"type": "object",
"description": "dataset query projection config",
"properties": {
"select": {
"type": "object",
"description": "mongo db selector",
"patternProperties": {
"^[a-zA-Z0-9_]+(\\.[a-zA-Z0-9]+)*$": {
"enum": [0, 1]
}
}
}
}
}
}
}