hdresearch/nolita

"schema" property causes bad merge when using page API on nolita serve

Opened this issue · 1 comments

Page API schema examples at, eg. localhost:3000 when using npx nolita serve, include this in the request body:

{ schema: "string" }

but this will create this error, presumably because it’s not a zod object, just an incoming string:

TypeError: merging._def.shape is not a function
    at Object.shape (/root/.npm/_npx/bb86540f6c337315/node_modules/nolita/node_modules/zod/lib/types.js:2003:33)
    at parseObjectDef (/root/.npm/_npx/bb86540f6c337315/node_modules/nolita/node_modules/zod-to-json-schema/dist/cjs/parsers/object.js:80:31)
    at selectParser (/root/.npm/_npx/bb86540f6c337315/node_modules/nolita/node_modules/zod-to-json-schema/dist/cjs/parseDef.js:92:51)
    at parseDef (/root/.npm/_npx/bb86540f6c337315/node_modules/nolita/node_modules/zod-to-json-schema/dist/cjs/parseDef.js:52:24)
    at parseOptionalDef (/root/.npm/_npx/bb86540f6c337315/node_modules/nolita/node_modules/zod-to-json-schema/dist/cjs/parsers/optional.js:7:43)
    at selectParser (/root/.npm/_npx/bb86540f6c337315/node_modules/nolita/node_modules/zod-to-json-schema/dist/cjs/parseDef.js:123:55)
    at parseDef (/root/.npm/_npx/bb86540f6c337315/node_modules/nolita/node_modules/zod-to-json-schema/dist/cjs/parseDef.js:52:24)
    at Object.entries.reduce.properties (/root/.npm/_npx/bb86540f6c337315/node_modules/nolita/node_modules/zod-to-json-schema/dist/cjs/parsers/object.js:83:58)
    at Array.reduce (<anonymous>)
    at parseObjectDef (/root/.npm/_npx/bb86540f6c337315/node_modules/nolita/node_modules/zod-to-json-schema/dist/cjs/parsers/object.js:80:40

Removing the schema field from submission in /step, /browse etc fixes this.

@AlephNotation is there a different example we should be using in the schema besides "schema": "string",? Or is string what it's supposed to use?