Skip to content

Commit

Permalink
Add validation for saveWebClientState, postMovie, and postScreenshot (#…
Browse files Browse the repository at this point in the history
…390)

* Add json schema for web client state

* Update schemas

* Add json validator to composer

* Add schema validation test

* Add web client state test

* Add schema files in docroot

* Update schemas

* Add validation for post endpoints

* update movie/screenshot schemas

* ignore autogenerated docroot/schema folder

* Add shebang and set -e to deploy.sh

* Move schema files to docroot/schema

* Update management/schema readme

* Add generated image_layer.schema.json

* Update validate.py to use local files

* Use data provider for schema tests

* Add expectExceptionMessage to WebClientTest
  • Loading branch information
dgarciabriseno authored Jun 20, 2024
1 parent 580224c commit bc7bca8
Show file tree
Hide file tree
Showing 61 changed files with 5,186 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ docroot/docs/v2
docroot/status.xml
py_env
py_venv_local_sunpy
vendor
vendor
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
},
"require": {
"helioviewer/event-interface": "v0.2.1",
"matomo/device-detector": "dev-master"
"matomo/device-detector": "dev-master",
"opis/json-schema": "^2.3"
},
"require-dev": {
"phpunit/phpunit": "^9.6"
Expand Down
192 changes: 191 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions docroot/schema/celestial_bodies.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://api.helioviewer.org/schema/celestial_bodies.schema.json",
"title": "Celestial Bodies",
"description": "State information for the celestial_bodies section of the Helioviewer UI",
"additionalProperties": false,
"properties": {
"soho": {
"type": "array",
"items": {
"type": "string",
"enum": [
"soho-mercury-tree-label",
"soho-venus-tree-label",
"soho-mars-tree-label",
"soho-jupiter-tree-label",
"soho-saturn-tree-label",
"soho-uranus-tree-label",
"soho-neptune-tree-label",
"soho-psp-tree-branch",
"soho-psp-tree-label",
"soho-psp-tree-trajectory"
]
}
},
"stereo_a": {
"type": "array",
"items": {
"type": "string",
"enum": [
"stereo_a-mercury-tree-label",
"stereo_a-earth-tree-label",
"stereo_a-venus-tree-label",
"stereo_a-mars-tree-label",
"stereo_a-jupiter-tree-label",
"stereo_a-saturn-tree-label",
"stereo_a-uranus-tree-label",
"stereo_a-neptune-tree-label",
"stereo_a-psp-tree-branch",
"stereo_a-psp-tree-label",
"stereo_a-psp-tree-trajectory"
]
}
},
"stereo_b": {
"type": "array",
"items": {
"type": "string",
"enum": [
"stereo_b-mercury-tree-label",
"stereo_b-venus-tree-label",
"stereo_b-earth-tree-label",
"stereo_b-mars-tree-label",
"stereo_b-jupiter-tree-label",
"stereo_b-saturn-tree-label",
"stereo_b-uranus-tree-label",
"stereo_b-neptune-tree-label",
"stereo_b-psp-tree-branch",
"stereo_b-psp-tree-label",
"stereo_b-psp-tree-trajectory"
]
}
}
}
}
35 changes: 35 additions & 0 deletions docroot/schema/client_state.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://api.helioviewer.org/schema/client_state.schema.json",
"title": "Client State",
"description": "State information used to initialize the helioviewer.org UI",
"type": "object",
"additionalProperties": false,
"properties": {
"date": { "type": "number" },
"centerX": { "type": "number" },
"centerY": { "type": "number" },
"imageScale": { "type": "number" },
"eventLayers": {
"$ref": "https://api.helioviewer.org/schema/event_layers.schema.json"
},
"imageLayers": {
"type": "array",
"items": {
"$ref": "https://api.helioviewer.org/schema/image_layer.schema.json"
}
},
"celestialBodies": {
"$ref": "https://api.helioviewer.org/schema/celestial_bodies.schema.json"
}
},
"required": [
"date",
"centerX",
"centerY",
"imageScale",
"eventLayers",
"imageLayers",
"celestialBodies"
]
}
68 changes: 68 additions & 0 deletions docroot/schema/event_layers.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://api.helioviewer.org/schema/event_layers.schema.json",
"title": "Event Layers",
"description": "Contains visibility settings for multiple groups of events",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z_]{1,11}$": {
"type": "object",
"additionalProperties": false,
"required": ["labels_visible", "layers"],
"properties": {
"id": {
"type": "string",
"enum": [
"HEK",
"CCMC",
"RHESSI"
]
},
"visible": { "type": "boolean" },
"labels_visible": { "type": "boolean" },
"markers_visible": { "type": "boolean" },
"layer_available_visible": { "type": "boolean" },
"layers": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["frms", "event_type", "event_instances"],
"properties": {
"frms": {
"type": "array",
"items": {
"type": "string",
"pattern": "^\\w+$",
"minLength": 1,
"maxLength": 30
}
},
"open": {
"type": "integer",
"minimum": 0,
"maximum": 1
},
"event_type": {
"type": "string",
"pattern": "^[A-Z0-9]{2}$",
"maxLength": 2
},
"event_instances": {
"type": "array",
"maxItems": 20,
"items": {
"type": "string",
"pattern": "^[a-zA-Z-]{2}--[a-zA-Z0-9_]{1,30}--[a-zA-Z0-9_.\\()+]+$",
"minLength": 1,
"maxLength": 150
}
}
}
}
}
}
}
}
}
Loading

0 comments on commit bc7bca8

Please sign in to comment.