Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON validation schema of type "array" not supported #677

Open
johnaohara opened this issue Sep 26, 2023 · 1 comment
Open

JSON validation schema of type "array" not supported #677

johnaohara opened this issue Sep 26, 2023 · 1 comment
Labels
branch/master The master branch branch/stable The stable branch type/bug Something isn't working

Comments

@johnaohara
Copy link
Member

currently a json schema defined for a horreum schema can not be of type "array".
e.g. with the following JSON validation schema

{
  "$id": "urn:boot-time-verbose:01",
  "type": "array",
  "items": [
    {
      "type": "object",
      "required": [
        "date",
        "sample",
...

Uploading a json document such as;

[
  {
    "date": "2023-09-18T13:02:00.951793Z",
    "sample": 1,
...
  }
]

results in a schema validation error: $: object found, array expected

This error occurs due to processing the run data during import, imported data of type Array are iterated and the schema is added to each object in the array, rather than the entire array being treated as the the run data

Horreum should either;

  • explicitly state that it does not support json schemas where the root element is an array type, amd display a warning/error when the json schema is defined.

or

  • support all valid json schemas and handle arrays accordingly
@johnaohara johnaohara added type/bug Something isn't working branch/master The master branch branch/stable The stable branch labels Sep 26, 2023
@johnaohara
Copy link
Member Author

This can be worked around by wrapping the array in an Object type, so I think is low priority.

But as it is Horreum does not support valid JSON schema's if the root element type is "array" due to the way the data is imported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch/master The master branch branch/stable The stable branch type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant