feat: support external JSON schema file references in type generation#14749
Merged
GermanJablo merged 1 commit intoNov 27, 2025
Merged
Conversation
- Add cwd parameter to json-schema-to-typescript compile() call - Enables to external .json schema files in typescriptSchema - Add test with external schema file reference - Document external schema reference usage
GermanJablo
approved these changes
Nov 27, 2025
Contributor
GermanJablo
left a comment
There was a problem hiding this comment.
That makes sense to me! Thank you!
Contributor
|
🚀 This is included in version v3.66.0 |
zubricks
pushed a commit
that referenced
this pull request
Jan 6, 2026
…#14749) ## Description Enables the use of external JSON schema file references in type generation by adding the `cwd` parameter to `json-schema-to-typescript`'s `compile()` function. ## Changes - Added `cwd: process.cwd()` parameter to `generateTypes()` compile call - Enables `$ref` pointers to external `.json` schema files in `typescriptSchema` field config - Added test case with external schema file reference - Documented external schema reference usage in generating-types.mdx ## Test Coverage ✅ New test: `resolves external schema file references` - Created `test/types/schemas/custom-type.json` as external schema - Added field with `typescriptSchema` referencing the external file - Verified generated types include the external type correctly ## Example Usage ```typescript // payload.config.ts { typescript: { schema: [ ({ jsonSchema }) => { jsonSchema.definitions.MyType = { $ref: './schemas/my-type.json' } return jsonSchema }, ] } } ``` External references are resolved relative to `process.cwd()`. ## Related Issue This was identified during investigation of JSON Schema parser capabilities. The `cwd` parameter is a standard `json-schema-to-typescript` option that was not being passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Enables the use of external JSON schema file references in type generation by adding the
cwdparameter tojson-schema-to-typescript'scompile()function.Changes
cwd: process.cwd()parameter togenerateTypes()compile call$refpointers to external.jsonschema files intypescriptSchemafield configTest Coverage
✅ New test:
resolves external schema file referencestest/types/schemas/custom-type.jsonas external schematypescriptSchemareferencing the external fileExample Usage
External references are resolved relative to
process.cwd().Related Issue
This was identified during investigation of JSON Schema parser capabilities. The
cwdparameter is a standardjson-schema-to-typescriptoption that was not being passed.