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
Fix `createAsyncapiFile` (`generate:after`) copying the source AsyncAPI document verbatim, which left external `$ref`s (e.g. `$ref: './commons/servers.yml#/...'`) unresolved in the generated output and broke runtime consumers such as `@asyncapi/keeper`. The hook now bundles the document via `@asyncapi/bundler` when it was loaded from a file on disk, inlining external `$ref`s into a single self-contained file. If no source file is available, or bundling fails, it falls back to writing the original source unchanged.
6
+
7
+
Note: refs are resolved relative to the source file's own directory only, so refs pointing outside a path reachable from there (e.g. a `commons/` folder reached only through a symlink) will not bundle and fall back to the verbatim source.
Copy file name to clipboardExpand all lines: apps/generator/docs/hooks.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,9 @@ It is a library of reusable hooks that you can use in your templates. You only h
92
92
This library consists of the following hooks:
93
93
|Hook name|Hook type|Description|
94
94
|---|---|---|
95
-
|`createAsyncapiFile`|`generate:after`| It creates an AsyncAPI file with the content of the spec file passed to the generator. By default, it creates the file in the root of the generation output directory. This hook also supports custom parameters that the user can pass to template generation. The parameter called `asyncapiFileDir` allows the user to specify the location where the spec file should be created. To make your template users use this parameter, you need to add it to the configuration of your template like other parameters |
95
+
|`createAsyncapiFile`|`generate:after`| It creates an AsyncAPI file with the content of the spec file passed to the generator. If the spec was loaded from a file on disk, external `$ref`s (e.g. `$ref: './commons/servers.yml#/...'`) are bundled via [`@asyncapi/bundler`](https://github.com/asyncapi/bundler) into a single self-contained file; otherwise, or if bundling fails, the original spec is written unchanged. By default, it creates the file in the root of the generation output directory. This hook also supports custom parameters that the user can pass to template generation. The parameter called `asyncapiFileDir` allows the user to specify the location where the spec file should be created. To make your template users use this parameter, you need to add it to the configuration of your template like other parameters |
96
+
97
+
> **Limitation:** refs are only resolved relative to the source file's own directory, so a `$ref` reachable only through another path (e.g. a symlink) won't bundle and falls back to the unresolved source.
96
98
97
99
1. In your template configuration in `package.json` specify you want to use this library and what hook exactly:
0 commit comments