Closed aeworxet closed 6 months ago
@KhudaDad414 @derberg @asyncapi/bounty_team
For anyone waiting on this PR who doesn't want to fork, and doesn't need x-origin
per se (but simply better deref), you can use @apidevtools/json-schema-ref-parser
in your local script before calling bundler
, i.e., just dereference first, e.g.:
import bundle from '@asyncapi/bundler';
import $RefParser from "@apidevtools/json-schema-ref-parser";
import { writeFileSync } from 'fs';
import { resolve } from "node:path"
import { mkdir } from "node:fs/promises"
process.chdir("specs")
const srcFileName = 'events.asyncapi.yml';
const outputBase = resolve("../generated/docs/specs") + "/"
const outputPath = `${outputBase}${srcFileName}`;
try {
await mkdir(outputBase, {recursive: true})
const clonedSchema = await $RefParser.dereference(srcFileName, {
dereference: {
excludedPathMatcher: (path) => path.includes("operations")
},
mutateInputSchema: false
});
const document = await bundle([clonedSchema], {
referenceIntoComponents: true,
});
writeFileSync(outputPath, document.yml());
console.log(`Bundled ${srcFileName} to ${outputPath}`)
} catch (err) {
console.error(err);
}
This PR is ready for merge, but it should be merged only AFTER https://github.com/asyncapi/optimizer/pull/216 is merged (it will be merged only to next
not master
) and Optimizer
1.0.0
is released, due to the transfer of functionality of moving components into components
to Optimizer
starting from its version v1.0.0.
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code
/rtm
:tada: This PR is included in version 0.5.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
This PR adds the generation of the property
x-origin
during the dereferencing process. Propertyx-origin
is used for origin tracing inBundler
and component naming inOptimizer
.It originated from this comment in a year-long discussion:
Thus, property
x-origin
contains historical values of dereferenced$ref
s, which are also used byOptimizer
starting from its version v1.0.0, to give meaningful names to components it moves through the AsyncAPI Document.Partial resolution of https://github.com/asyncapi/bundler/issues/141