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

Support for lazy recursive JSON schemas #1278

Open
lordrip opened this issue Jul 31, 2023 · 2 comments · May be fixed by #1282
Open

Support for lazy recursive JSON schemas #1278

lordrip opened this issue Jul 31, 2023 · 2 comments · May be fixed by #1282
Assignees
Labels
Area: Bridge Affects some of the bridge packages Bridge: JSON Schema Affects the uniforms-bridge-json-schema package Type: Feature New features and feature requests
Milestone

Comments

@lordrip
Copy link

lordrip commented Jul 31, 2023

  • Motivation why you'd like to see this in uniforms.
    In case there's a recursive JSON Schema, it would be nice to support lazy evaluation of such schema from the JSONSchemaBridge class

  • Examples of how others could use this feature.
    Offering a mechanism to initialize JSONSchemaBridge up to a certain recursion level would allow rendering only up to a level of nested form elements.

Hi team, I saw another similar issue closed about supporting lazy recursive schemas #596, but I'm not sure if managed to get a consensus about how to implement such capability.

Considering the following schema (this is a simplified version of a more complex one)

{
  "$schema": "https://json-schema.org/draft-04/schema#",
  "type": "array",
  "items": {
    "maxProperties": 1,
    "definitions": {
      "org.apache.camel.model.OnExceptionDefinition": {
        "type": "object",
        "properties": {
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/items/definitions/org.apache.camel.model.ProcessorDefinition"
            }
          }
        }
      },
      "org.apache.camel.model.ProcessorDefinition": {
        "type": "object",
        "maxProperties": 1,
        "properties": {
          "aggregate": {
            "$ref": "#/items/definitions/org.apache.camel.model.AggregateDefinition"
          }
        }
      },
      "org.apache.camel.model.AggregateDefinition": {
        "type": "object",
        "properties": {
          "aggregation-strategy": {
            "type": "string"
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/items/definitions/org.apache.camel.model.ProcessorDefinition"
            }
          }
        },
        "required": [
          "aggregation-strategy"
        ]
      }
    },
    "properties": {
      "on-exception-recursive": {
        "$ref": "#/items/definitions/org.apache.camel.model.OnExceptionDefinition"
      }
    }
  }
}

you can see that there's a recursive property from:

aggregate -> steps -> aggregate -> steps

The idea would be to either limit the nested level up to point or to offer a lazy mechanism to render level by level depending on the user interaction.

I was checking the JSONSchemaBridge#getInitialValue but is not clear to me where to place a limit or even if this is the best place to do such thing.

Thanks in advance for the help 👍

@Monteth
Copy link
Member

Monteth commented Aug 11, 2023

Hello @lordrip, thank you for this question.
I think it is possible for Uniforms to support some kinds of recursive schemas. You can take a look at my draft #1282 and see if it could help you.

@Monteth Monteth self-assigned this Aug 11, 2023
@lordrip
Copy link
Author

lordrip commented Aug 11, 2023

Hi @Monteth, this is great 👍.

In a couple weeks I need to work on custom fields to kinda have a workaround. In the meantime, please let me know if I can help somehow, I have a recursive schema to try out as well (although the recursive schema from your PR seems more than good to test it out)

Thanks for the response

@github-project-automation github-project-automation bot moved this to Needs triage in Open Source Aug 18, 2023
@Monteth Monteth moved this from Needs triage to Concept in Open Source Aug 18, 2023
@Monteth Monteth added this to the v4.0 milestone Aug 18, 2023
@kestarumper kestarumper moved this from Concept to In progress in Open Source Sep 29, 2023
@kestarumper kestarumper added Type: Feature New features and feature requests Area: Bridge Affects some of the bridge packages Bridge: JSON Schema Affects the uniforms-bridge-json-schema package labels Feb 26, 2024
@kestarumper kestarumper moved this from In progress to Review in Open Source May 10, 2024
@piotrpospiech piotrpospiech moved this from Review to In progress in Open Source May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Bridge Affects some of the bridge packages Bridge: JSON Schema Affects the uniforms-bridge-json-schema package Type: Feature New features and feature requests
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

3 participants