From 62180a482e75de2f343baa95f9b95137ed8a114f Mon Sep 17 00:00:00 2001 From: devilkiller-ag Date: Wed, 31 Jan 2024 13:48:40 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20rectified=20version=20errors=20for?= =?UTF-8?q?=20common=20schemas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- {definitions/common => common}/avroSchema_v1.json | 0 {definitions/common => common}/openapiSchema_3_0.json | 0 tools/bundler/index.js | 11 +++++------ 3 files changed, 5 insertions(+), 6 deletions(-) rename {definitions/common => common}/avroSchema_v1.json (100%) rename {definitions/common => common}/openapiSchema_3_0.json (100%) diff --git a/definitions/common/avroSchema_v1.json b/common/avroSchema_v1.json similarity index 100% rename from definitions/common/avroSchema_v1.json rename to common/avroSchema_v1.json diff --git a/definitions/common/openapiSchema_3_0.json b/common/openapiSchema_3_0.json similarity index 100% rename from definitions/common/openapiSchema_3_0.json rename to common/openapiSchema_3_0.json diff --git a/tools/bundler/index.js b/tools/bundler/index.js index e0f0533e..b5943d94 100644 --- a/tools/bundler/index.js +++ b/tools/bundler/index.js @@ -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'; @@ -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); @@ -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`;