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
{{ message }}
Repository navigation
Support configurable JSON Schema filenames - #12619
Support a file-name template for schema filenames, including .schema.json and .schema.yaml. Implicit schema ids and references follow the configured filenames.,> ,> Directory paths are not allowed in the template; use emitter-output-dir to configure the output directory.,> Templates resolving to empty names or directory markers are rejected, and output filename collisions are reported as errors instead of overwriting schemas.,> ,> yaml,> options:,> "@typespec/json-schema":,> file-type: json,> file-name: "{name}.schema.{ext}",>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Distinct schema IDs can resolve to the same output path and silently overwrite a schema, while accepted empty or directory-marker filenames can cause emission to fail.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Filename handling can target the output directory for empty declaration names and produce incorrect schema IDs and references when filenames contain unescaped '#' characters.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The filename guard still permits ?, causing URI consumers to misinterpret emitted schema filenames as queries and breaking cross-schema references.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Reject query delimiters in schema filenames
packages/json-schema/src/on-emit.ts:31
The new guard still accepts file-name: "{name}?schema.{ext}", which writes Bar?schema.json, but #getDeclId (packages/json-schema/src/json-schema-emitter.ts:1126–1141) uses that filename verbatim: URI consumers interpret it as resource Bar with query schema.json, so cross-schema references do not locate the emitted file. Reject ? alongside fragment delimiters with an actionable diagnostic and a regression test.
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
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.
JSON Schema files currently use fixed
.jsonor.yamlfilenames, preventing users from choosing conventions such asWidget.schema.json.Add a
file-nametemplate with{name}and{ext}placeholders:This produces
Widget.schema.json; selecting YAML producesWidget.schema.yaml. Implicit$idvalues and references follow the configured filenames, while explicit IDs, bundle filenames, and default behavior remain unchanged.Directory separators are rejected with an actionable diagnostic; output placement remains controlled by
emitter-output-dir.