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

Fixes for #3228 (playground dev crash), #3213 (Ajv8 additionalProperties validation) #3229

Merged
merged 2 commits into from Nov 5, 2022

Conversation

nickgros
Copy link
Contributor

@nickgros nickgros commented Nov 4, 2022

Fixes #3228, #3213

Playground

  • Playground localValidator should use @rjsf/validator-ajv8
  • Upgrade Vite and @vitejs/plugin-react to latest

@rjsf/validator-ajv8

  • Alias ajv to ajv8 because in the playground, Vite erroneously imports Ajv 6
  • Report any schema error thrown by Ajv
  • Disable Ajv's strict mode by default
  • Add RJSF-specific additional properties keywords to Ajv to prevent errors from being reported in strict mode.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

- Fix vite dev server
- Assign `globalThis` to window.global to fix issue in semantic
- ajv-formats `addFormats` should not be called with a nullish value
Playground
- Playground `localValidator` should use @rjsf/validator-ajv8
- Upgrade Vite and @vitejs/plugin-react to latest

@rjsf/validator-ajv8
- Alias `ajv` to `ajv8` because in the playground, Vite erroneously imports Ajv 6
- Report any schema error thrown by Ajv
- Disable Ajv's strict mode by default
- Add RJSF-specific additional properties keywords to Ajv to prevent errors from being reported in strict mode.
-
@nickgros nickgros changed the title @rjsf/playground - Fix immediate crash in Vite development server Fixes for #3228 (playground dev crash), #3213 (Ajv8 additionalProperties validation) Nov 5, 2022
@@ -27,13 +27,13 @@
]
},
"dependencies": {
"ajv": "^8.11.0",
"ajv8": "npm:ajv@^8.11.0",
Copy link
Contributor Author

@nickgros nickgros Nov 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the reason the dev server was crashing was because Vite was resolving 'ajv' to Ajv 6 in '@rjsf/validator-ajv8'. I could not find a Vite/esbuild configuration option to handle this (maybe it's a bug?). This fixes the issue.

Will this affect anything for users?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe switch things in the ajv6 validator instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix doesn't work if I just change it for ajv6, not sure why.

"@rjsf/utils": "^5.0.0-beta.1"
"@rjsf/utils": "^5.0.0-beta.12"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can revert this one since the ^ will get it to .12

Copy link
Member

@heath-freenome heath-freenome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just consider making the ajv6 validator the one using the alias since it is more likely to be deleted in the future

@nickgros nickgros merged commit 651bc02 into rjsf-team:main Nov 5, 2022
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

Successfully merging this pull request may close these issues.

@rjsf/playground: Vite dev server broken
2 participants