Skip to content

Commit

Permalink
✨ rectified version errors for common schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
devilkiller-ag committed Jan 31, 2024
1 parent 8eaf571 commit 62180a4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
File renamed without changes.
File renamed without changes.
11 changes: 5 additions & 6 deletions tools/bundler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require('fs');
const traverse = require('json-schema-traverse');
const { url } = require('inspector');
const definitionsDirectory = path.resolve(__dirname, '../../definitions');
const commonSchemasDir = path.resolve(__dirname, '../../definitions/common');
const commonSchemasDirectory = path.resolve(__dirname, '../../common');
const bindingsDirectory = path.resolve(__dirname, '../../bindings');
const outputDirectory = path.resolve(__dirname, '../../schemas');
const JSON_SCHEMA_PROP_NAME = 'json-schema-draft-07-schema';
Expand Down Expand Up @@ -60,11 +60,10 @@ async function loadBindings(bundler) {
}
}

async function loadingCommonSchemas(bundler) {
async function loadCommonSchemas(bundler) {
// Add common schemas to all versions
const commonSchemas = await fs.promises.readdir(commonSchemasDir);
const commonSchemaFiles = commonSchemas.map((file) => fs.readFileSync(path.resolve(commonSchemasDir, file)));
console.log(commonSchemaFiles);
const commonSchemas = await fs.promises.readdir(commonSchemasDirectory);
const commonSchemaFiles = commonSchemas.map((file) => path.resolve(commonSchemasDirectory, file));
for(const commonSchemaFile of commonSchemaFiles) {
const commonSchemaFileContent = require(commonSchemaFile);
bundler.add(commonSchemaFileContent);
Expand All @@ -89,7 +88,7 @@ async function loadingCommonSchemas(bundler) {
const outputFileWithoutId = path.resolve(outputDirectory, `${version}-without-$id.json`);
const versionDir = path.resolve(definitionsDirectory, version);
await loadDefinitions(Bundler, versionDir);
await loadingCommonSchemas(Bundler);
await loadCommonSchemas(Bundler);
await loadBindings(Bundler);

const filePathToBundle = `file://${versionDir}/asyncapi.json`;
Expand Down

0 comments on commit 62180a4

Please sign in to comment.