vazco / uniforms

A React library for building forms from any schema.

Home Page:https://uniforms.tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for jsonschema "const" keyword overriding "type"

helt opened this issue · comments

commented

If a property does not have a type constraint, form generation will fail.

According to my understanding of the JSONSchema spec, the type constraint is optional, and may be omitted.

For example, the JSONSchema below is valid, and also accepted by ajv.

{
          "properties": {
            "type": { "const": "Visualization", "title": "Type" },
          },
          "required": [],
          "title": "constOverType",
          "type": "object",
        }

uniforms complains

Uncaught Invariant Violation: Unsupported field type: undefined
    at invariant (webpack-internal:///./node_modules/invariant/browser.js:38:15)
    at eval (webpack-internal:///./node_modules/uniforms-mui/esm/AutoField.js:46:60)
    at AutoField (webpack-internal:///./node_modules/uniforms/esm/createAutoField.js:23:27)
    at renderWithHooks (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:16305:18)
    at mountIndeterminateComponent (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:20069:13)
    at beginWork (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:21582:16)
    at HTMLUnknownElement.callCallback (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:4164:14)
    at Object.invokeGuardedCallbackDev (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:4213:16)
    at invokeGuardedCallback (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:4277:31)
    at beginWork$1 (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:27446:7)
    at performUnitOfWork (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:26552:12)
    at workLoopSync (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:26461:5)
    at renderRootSync (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:26429:7)
    at recoverFromConcurrentError (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:25845:20)
    at performSyncWorkOnRoot (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:26091:20)
    at flushSyncCallbacks (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:12042:22)
    at eval (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:25646:13)