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

Error with $ref: reference resolves to more than one schema #4048

Closed
4 of 5 tasks
jag43 opened this issue Jan 17, 2024 · 5 comments
Closed
4 of 5 tasks

Error with $ref: reference resolves to more than one schema #4048

jag43 opened this issue Jan 17, 2024 · 5 comments

Comments

@jag43
Copy link

jag43 commented Jan 17, 2024

Prerequisites

What theme are you using?

mui

Version

5.16.1

Current Behavior

When using JSON pointer $refs I'm getting an error on submission: reference "locations.json" resolves to more than one schema

Expected Behavior

No error, form performs validation as expected

Steps To Reproduce

https://github.com/jag43/rjsf-resolves-to-more-than-one-schema

  1. Install the required packages by running npm install
  2. Run the vite dev server with npm run dev
  3. Press the form submit button
  4. Open dev tools and see the error in console

Environment

- OS: Windows 10 22H2
- Node: v18.18.0
- npm: 9.8.1

Anything else?

No response

@jag43 jag43 added bug needs triage Initial label given, to be assigned correct labels and assigned labels Jan 17, 2024
@jag43 jag43 changed the title <title> Error with $ref: reference resolves to more than one schema Jan 17, 2024
@magaton
Copy link

magaton commented Jan 19, 2024

I think you need to declare reference to location.json differently, not using /#defs prefix.

See this comment with explanation how ajv works

@jag43
Copy link
Author

jag43 commented Jan 19, 2024

Thanks for your reply, I'm using the # json pointer because according to the RJSF docs on Schema definitions and references
its the only type of ref RJSF supports

Note that this library only supports local definition referencing. The value in the $ref keyword should be a JSON Pointer in URI fragment identifier format.

After reading the json schema docs for $id I noticed it says this:

When the $id keyword appears in a subschema, it means something slightly different. See the bundling section for more.

I don't fully understand why but after removing the $id from the sub-schema (in $defs) it appears to be working now

@magaton
Copy link

magaton commented Jan 19, 2024

Yes, this is exactly what is explained in the comment I referenced.
Also see this issue

@heath-freenome
Copy link
Member

@jag43 Has this issue been resolved? If so, please close

@heath-freenome heath-freenome added question awaiting response ajv and removed bug needs triage Initial label given, to be assigned correct labels and assigned labels Jan 26, 2024
@jag43
Copy link
Author

jag43 commented Jan 26, 2024

Yes I've resolved this thank you for your help

@jag43 jag43 closed this as completed Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants