-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Prerequisites
- I have searched the existing issues
- I understand that providing a SSCCE example is tremendously useful to the maintainers.
- I have read the documentation
- Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
What theme are you using?
core
Version
5.24.7
Current Behavior
The following code throws an error:
import { getDefaultFormState, RJSFSchema } from '@rjsf/utils';
import validator from '@rjsf/validator-ajv8';
const schema: RJSFSchema = {
definitions: {
address: {
type: 'object',
properties: {
street_address: { type: 'string' },
city: { type: 'string' },
state: { type: 'string' },
},
required: ['street_address', 'city', 'state'],
},
},
type: 'object',
properties: {
billing_address: { $ref: '#/definitions/address' },
shipping_address: { $ref: '#/definitions/address' },
},
};
try {
getDefaultFormState(validator, schema, {});
} catch (e) {
console.log('Error calling retrieveSchema:', e);
}
This is the error thrown:
Error: Could not find a definition for #/definitions/address.
at findSchemaDefinitionRecursive (chunk-IEJR3CZA.js?v=69f3d9b8:8602:11)
at findSchemaDefinition (chunk-IEJR3CZA.js?v=69f3d9b8:8625:10)
at resolveAllReferences (chunk-IEJR3CZA.js?v=69f3d9b8:9545:23)
at chunk-IEJR3CZA.js?v=69f3d9b8:9552:21
at chunk-IEJR3CZA.js?v=69f3d9b8:9108:12
at chunk-IEJR3CZA.js?v=69f3d9b8:8694:11
at baseForOwn (chunk-IEJR3CZA.js?v=69f3d9b8:8709:20)
at transform (chunk-IEJR3CZA.js?v=69f3d9b8:9107:55)
at resolveAllReferences (chunk-IEJR3CZA.js?v=69f3d9b8:9550:26)
at resolveReference (chunk-IEJR3CZA.js?v=69f3d9b8:9528:25)
Expected Behavior
getDefaultFormState()
should return the default form data.
Steps To Reproduce
- Visit https://stackblitz.com/edit/vitejs-vite-mw8zql5w?file=src%2Fmain.ts&terminal=dev
- Open developer tools to see the logged error.
Environment
- OS: MacOS
- Node: v20.13.1
- npm: 10.5.2
Anything else?
- The same error is thrown when calling
retrieveSchema(validator, schema);
- Using this schema directly with a
@rjsf/core
Form does not throw.