-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bundling and inlining of referenced schemas #3430
Conversation
All changed packages have been documented.
Show changes
|
You can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/3430/ Check the website changes at https://tspwebsitepr.z22.web.core.windows.net/prs/3430/ |
@Veetaha if you like you can check the behavior in the playground link above and see if it meets your approval. |
Co-authored-by: Vitalii Kryvenko <[email protected]>
Fixes #3369 by changing how types are bundled. In particular, when a type is not a JSON Schema type, we never create a root schema for it. Instead, it is inlined into the defs of any schema which references it, and referenced using a JSON pointer. This PR makes bundling have essentially no impact on emitted schemas, and is merely a way to bundle them into a single file.
The approach is as follows:
$id
of the bundled schemas now includes the file path as it does for non-bundled schemas (whereas before it was just the type name)In terms of implementation, the basic approach is to not handle bundling via the emitter framework source files. Instead, we always create source files for root schemas, and inline the necessary defs as we did before (but now using JSON pointers). Then when we're about to write source files, if we're bundling we assemble the bundle and emit that single file, otherwise we emit each source file that contains a root schema.
Todo: