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
</details>
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
### Link to the code that reproduces this issue
https://github.com/payloadcms/payload/blob/main/packages/payload/src/bin/generateTypes.ts#L32
### Reproduction Steps
1. Create new project `pnpx create-payload-app@latest -t website`
2. Add JSON field to `src/collections/Posts/index.tsx`
3. Specify a local jsonSchema using `$ref` (same as in the ticket description)
4. Run `pnpm generate:types`
5. [BUG] Unable to generate the types, and console will show error.
### Which area(s) are affected? (Select all that apply)
area: core
### Environment Info
```text
Binaries:
Node: 20.18.2
npm: N/A
Yarn: N/A
pnpm: 9.14.2
Relevant Packages:
payload: 3.23.0
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Tue Jan 21 10:23:32 UTC 2025
Available memory (MB): 27015
Available CPU cores: 11
The text was updated successfully, but these errors were encountered:
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
```typescript // payload-types.ts export interface Post { // ...snip criteria_json?: { _or?: Condition[]; _and?: Condition[]; }; }The text was updated successfully, but these errors were encountered: