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

BUG - Song does not merge definitions from uploaded schemas #876

Open
pvanheus opened this issue Oct 29, 2024 · 0 comments
Open

BUG - Song does not merge definitions from uploaded schemas #876

pvanheus opened this issue Oct 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@pvanheus
Copy link

If an uploaded schema contains a "definitions" section, this will be ignored when the schema is uploaded to Song. E.g.

{
    "name": "cholgen_sequence",
    "schema": {
        "type": "object",
        "definitions": {
            "species": {
                "type": "string",
                "enum": [
                    "Bos taurus",
                    "Homo sapiens"
                ]
            }
        },
        "properties": {
            "host": {
                "$ref": "#/definitions/species"
            }
        }
    }
}

The "definitions" section of this will be ignored, instead only the "definitions" from analysisBase.json will be included in the final rendered schema, resulting in an invalid schema.

Description

As mentioned above, the end result is an invalid schema. When this is used in production, an error occurs - see this trace. This trace was produced by trying to use this schema.

While sometimes the use of "definitions" can be avoided (e.g. in a later version of the schema mentioned above), this is often a useful features of JSON-Schema.

Expected Behaviour

The "definitions" section of schema should be merged with that of the analysisBase.json.

Actual Behaviour

As mentioned above, the contents of the "definitions" part of an uploaded schema is silently ignored.

Possible Fix

I think that the relevant code that merges schemas is in renderPayloadJsonSchema. This could be extended to merge "definitions" much as "properties" are currently merged.

Steps to Reproduce

  1. Upload the schema mentioned above in the description
  2. Try and upload a JSON document compliant with the schema

Your Environment

  • Version used: 5.2.0
  • Environment name and version (e.g. Chrome 39, node.js 5.4): Not relevant
  • Operating System and version (desktop or mobile): Upload was done using Muse
  • Link to your project: https://github.com/african-pathogen-archive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant