Skip to content

Evaluate support of Pydantic-v2 generated JSON Schemas #479

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

Closed
tcompa opened this issue May 7, 2024 · 1 comment
Closed

Evaluate support of Pydantic-v2 generated JSON Schemas #479

tcompa opened this issue May 7, 2024 · 1 comment
Labels
JSON Schemas Editing of WorkflowTask arguments based on JSON Schemas

Comments

@tcompa
Copy link
Collaborator

tcompa commented May 7, 2024

When testing the schemas in fractal-analytics-platform/fractal-tasks-core#737, we should be aware of how Pydantic V2 changes handling of Optional attributes (which includes the use of anyOf, and the fact that it seems that attributes are always included). The new behavior is sometimes confusing, see:

It's likely that this produces issues in the form generator.
By taking the example in pydantic/pydantic#7161 (comment), we end up with this JSON Schema:

{
  "properties": {
    "field": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Field"
    }
  },
  "title": "Model",
  "type": "object"
}

If we try it out in https://rjsf-team.github.io/react-jsonschema-form/, we find this behavior:

image
image

which IMO is a suboptimal UX, because it forces a two-steps process: first I need to decide whether to include the argument, and then I can decide whether/how to fill it.


TLDR We'll need to keep an eye on this, when experimenting with schema-based form generators.

@tcompa
Copy link
Collaborator Author

tcompa commented Jul 15, 2024

This issue was a FYI, but the plan is rather to make sure that fractal-tasks-core produces appropriate JSON Schemas (that is, without the additional anyOf pattern for nullable field) even with Pydantic v2.

Closing.

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
Development

No branches or pull requests

1 participant