You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But in the browser, when editing the JSON field, it does not suggest / validate based on the schema:
Troubleshooting this, it seems that the relative path being used for the $ref is the payload-types.ts? If I specify an external schema file as the jsonSchema.uri, then it seems to work in both the generation of types and in the browser field editor. But I don't want to host the external JSON schema file separately.
Expected behavior: should be able to generate types with JSON field with JSON schema using $ref
Describe the Bug
I have this
jsonSchema
that uses$ref
(recursively) to validate a JSON fieldJSON Schema
And during editing, the browser is able to autosuggest and validate the JSON field correctly:
But when I run
pnpm generate:types
, I get this error:generate:types Error
This worked before in Payload V2 and I did not have to explicitly specify the
JSONSchema
type as well.If i change the
$ref
from:
$ref: '#/definitions/condition'
to:
$ref: '#/definitions/posts/properties/criteria_json/definitions/condition'
then it's able to generate the types:
JSON field with schema - generated types
But in the browser, when editing the JSON field, it does not suggest / validate based on the schema:
Troubleshooting this, it seems that the relative path being used for the $ref is the
payload-types.ts
? If I specify an external schema file as thejsonSchema.uri
, then it seems to work in both the generation of types and in the browser field editor. But I don't want to host the external JSON schema file separately.Expected behavior: should be able to generate types with JSON field with JSON schema using $ref
Link to the code that reproduces this issue
https://github.com/payloadcms/payload/blob/main/packages/payload/src/bin/generateTypes.ts#L32
Reproduction Steps
pnpx create-payload-app@latest -t website
src/collections/Posts/index.tsx
$ref
(same as in the ticket description)pnpm generate:types
Which area(s) are affected? (Select all that apply)
area: core
Environment Info
The text was updated successfully, but these errors were encountered: