Enable JSON Schema multi file output - #2526
Open
kmturley wants to merge 8 commits into
Open
Conversation
Member
|
Thanks for this — a multi-file JSON Schema output (one file per definition, e.g. for schema registries or per-type A few things need to be resolved before this can merge, though:
Given the size of the ref-rewriting fix (item 1) plus the missing test infrastructure, this needs another pass. @kmturley, want to pick it back up? If not, we'd like to reimplement using this as the starting point, with credit for the original approach. |
No generated-output differences✅ This PR does not change generated outputs. |
…cement Addresses PR review feedback: - makeRef now emits file-qualified refs (Other.schema#/definitions/Other) for cross-file references in multi-file mode, instead of always emitting a same-document pointer that dangled once each definition moved to its own file. - Only the file that corresponds to the document's top-level type now carries the root $schema/type; other per-definition files no longer restate it. A dedicated root file is emitted when the top-level type isn't itself a named definition (e.g. a bare array or map), so the root type is never dropped. - Adds fixture coverage (test/fixtures.ts) that generates multi-file output alongside the existing schema-json fixture and verifies every emitted file parses as JSON, every $ref resolves, and the reassembled schema still validates the original input via Ajv. - Drops the now-dead multiFileOutput guards in startFile/endFile and fixes the startFile doc comment, which incorrectly claimed filenames are lowercased.
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.
This PR adds support for json schema multi file output.
Without

multi-file-outputoption:With

multi-file-outputoption:Tested with this repo:
https://github.com/kmturley/quicktype-typescript-input-demo
Replacing the
packages/quicktype-core/dist/language/JSONSchema.jsfile with the compiled file from this PR