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

Recursion #6

Open
Gerbert-Kaandorp opened this issue Jul 4, 2024 · 3 comments
Open

Recursion #6

Gerbert-Kaandorp opened this issue Jul 4, 2024 · 3 comments

Comments

@Gerbert-Kaandorp
Copy link

Hi,

Let me start by saying this is a awesome implementation of json-schema!
Using generators for this is genius.

I have been in the field for decades and to me this looks like a work of art.
Thank you.

fyi, I am playing around with this to turn it into a generic renderer.

However, while testing I used this code:

{
  "definitions": {
    "node": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/node"
          }
        }
      }
    }
  },
  "type": "object",
  "properties": {
    "tree": {
      "title": "Recursive references",
      "$ref": "#/definitions/node"
    }
  }
}
{
  "tree": {
    "children": [
      {
        "children": [],
        "name": "leaf"
      }
    ],
    "name": "root"
  }
}

From: https://rjsf-team.github.io/react-jsonschema-form/
The 'References' example.

It does not like that.

$ref: {
		*valid(url, value, schema) {
			 const refSchema = schema[refKey];

For fun I put the $dynamicRef code there and changed dynamic to false
const dynSchema = currentSchema.walk(url, { dynamic: false });

That worked 🤷

But honestly, I don't understand the fine balance of implementation and standard adherence here, so I dont even know it is a bug :)

I read you were asking for help, if there is any way I can contribute let me know.

🙇

@nuxodin
Copy link
Owner

nuxodin commented Jul 4, 2024

Hello Gerbert

Wow, thanks for the praise, that motivates me!

Strange, your example doesn't use $dynamicRef at all.

Did this error occur? "dynamicRef: no schema found, deref() called?"
I just saw in my code that the error message is not correct, it should be "ref: no schema..."

For fun I put the $dynamicRef code there and changed dynamic to false
const dynSchema = currentSchema.walk(url, { dynamic: false });

So your example doesn't go to currentSchema.walk at all, or rather shouldn't...🤔

It would be good if you could run the code somewhere online (codepen, jsfiddle), then I can take a better look at it.

I read you were asking for help, if there is any way I can contribute let me know.

I would prefer if someone who is familiar with the standard and Javascript could work on this project.

To be honest, I don't use the code myself yet and rarely get feedback from others. I only programmed it because I think JSON Schema is very promising for the future and I wanted a lean implementation that is also browser friendly.

@Gerbert-Kaandorp
Copy link
Author

Hi is this visible for you ?

https://jsfiddle.net/syqvfdxa/11/

Check the console for the error.

@nuxodin
Copy link
Owner

nuxodin commented Jul 8, 2024

Sorry, at the moment i have not time to take a look.
But I keep the issue open.

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

No branches or pull requests

2 participants