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

Schema: Create meta-schema for Nextflow schema #2436

Closed
Tracked by #2429
ewels opened this issue Sep 23, 2023 · 2 comments
Closed
Tracked by #2429

Schema: Create meta-schema for Nextflow schema #2436

ewels opened this issue Sep 23, 2023 · 2 comments
Labels

Comments

@ewels
Copy link
Member

ewels commented Sep 23, 2023

In the early days of the Nextflow schema files, I thought about making a "meta schema", but didn't do it as we were using off the shelf schema validation libraries. However, as the stack of 3rd party tools interacting with Nextflow schema has grown, it's become increasingly important to be explicit about what features and fields we do support, and what we don't.

Recently this led me to write a schema spec on the nf-validation plugin docs. I think a natural extension would be to also have a meta schema: a JSON schema document that describes the allowed structure of Nextflow schema. This should allow easy validation of schema files themselves, to ensure that they adhere to our restricted spec. And also include validation for our custom fields that we have added on top of the vanilla JSON schema spec.

@ewels
Copy link
Member Author

ewels commented Sep 27, 2023

Ok, I had a stab at writing a first draft of this. Must be one of the most complicated schema that I've ever written 😵

Still missing:

  • Defining which keys are required
  • Requiring that most strings are not zero-length
  • Conditional validation, eg. that maxLength is only for "type": "string"
  • Code comments! This is a schema for a schema, so a bunch of keys are named the same as schema properties, which is super confusing. When this gets committed to a repo it should ideally be in jsonc format so that we can litter it with hundreds of code comments explaining what each bit is doing.
{
    "$schema": "http://json-schema.org/draft-07/schema",
    "$id": "https://nextflow.io",
    "title": "Nextflow Schema Schema",
    "description": "Meta-schema to validate Nextflow parameter schema files",
    "type": "object",
    "properties": {
      "$schema": {
        "title": "schema",
        "type": "string",
      },
      "$id": {
        "title": "ID URI",
        "type": "string",
      },
      "title": {
        "title": "Title",
        "type": "string",
      },
      "description": {
        "title": "Description",
        "type": "string",
      },
      "type": {
        "title": "Top level type",
        "type": "string",
        "const": "object"
      },
      "definitions": {
        "title": "Parameter groups",
        "type": "object",
        "patternProperties": {
          "^.*$": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string"
               },
               "type": {
                 "const": "object"
               },
               "fa_icon": {
                "type": "string",
                "pattern": "^fa"
               },
               "description": {
                "type": "string"
               },
               "required": {
                "type": "array"
               },
               "properties": {
                 "type": "object",
                 "patternProperties": {
	                "^.*$": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": ["string", "boolean", "integer", "number"]
                        },
                        "format": {
                          "type": "string",
                          "enum": ["file-path", "directory-path", "path"]
                        },
                        "exists": {
                          "type": "boolean"
                        },
                        "mimetype": {
                          "type": "string",
                          "pattern": ".+/.+"
                        },
                        "pattern": {
                          "type": "string"
                        },
                        "schema": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "help_text": {
                          "type": "string"
                        },
                        "fa_icon": {
                          "type": "string",
                          "pattern": "^fa"
                        },
                        "errorMessage": {
                          "type": "string"
                        },
                        "hidden": {
                          "type": "boolean"
                        },
                        "minLength": {
                          "type": "integer"
                        },
                        "maxLength": {
                          "type": "integer"
                        },
                        "minimum": {
                          "type": "integer"
                        },
                        "maximum": {
                          "type": "integer"
                        }
                      }
                    }
                 }
               }
             }
           }
         }
      },
      "allOf": {
        "title": "Combine definition groups",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "$ref": {
              "type": "string",
              "pattern": "^#/definitions/"
            }
          }
        }
      },
    }
}

@ewels ewels changed the title Create meta-schema for Nextflow schema Schema: Create meta-schema for Nextflow schema Sep 28, 2023
ewels added a commit to nextflow-io/nf-validation that referenced this issue Nov 17, 2023
@ewels
Copy link
Member Author

ewels commented Nov 17, 2023

Moved this to nextflow-io/nf-validation#133 and added in required fields + minimum string lengths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant