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

Adapt to JSON Schema 2020-12 changes in items #534

Closed
tcompa opened this issue Jul 23, 2024 · 0 comments · Fixed by #535
Closed

Adapt to JSON Schema 2020-12 changes in items #534

tcompa opened this issue Jul 23, 2024 · 0 comments · Fixed by #535
Labels
JSON Schemas Editing of WorkflowTask arguments based on JSON Schemas

Comments

@tcompa
Copy link
Collaborator

tcompa commented Jul 23, 2024

There is at least one more issue related to #531, which will require a bit more work (i.e. handling/testing pydantic_v1 and pydantic_v2 schemas in different ways).


Pydantic V2 generates JSON Schemas that comply with draft 2020-12, which means that they follow the new style for items: https://json-schema.org/draft/2020-12/release-notes#changes-to-items-and-additionalitems. Briefly

The items and additionalItems keywords have been replaced with prefixItems and items where prefixItems has the same functionality as the array-of-schemas for of the old items and the new items keyword has the same functionality as the old additionalItems keyword.


Starting from a task Python function with an argument arg_A: tuple[int, int] = (1, 1), we end up with this kind of JSON Schema:

{
  "additionalProperties": false,
  "properties": {
    "arg_A": {
      "default": [
        1,
        1
      ],
      "maxItems": 2,
      "minItems": 2,
      "prefixItems": [
        {
          "type": "integer"
        },
        {
          "type": "integer"
        }
      ],
      "title": "Arg A",
      "type": "array",
      "description": "Description of arg_A."
    }
  },
  "type": "object",
  "title": "TaskFunction"
}

which currently cannot be loaded in fractal-web, due to error compiling schema Error: strict mode: unknown keyword: "prefixItems".


Since we need to tackle this question on the form-generation side, let's also check whether we should configure ajv differently for the two pydantic_v1/v2 cases, that is by specifying the JSON Schema draft explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSON Schemas Editing of WorkflowTask arguments based on JSON Schemas
Projects
1 participant