Skip to content

Commit

Permalink
fix: Changes in number of components calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Adi-204 committed Jan 15, 2025
1 parent e894f55 commit 8dabafe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions src/commands/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class Inspect extends Command {

static readonly flags = {
...inspectFlags(),
...proxyFlags(), // Merge proxyFlags with validateFlags
...proxyFlags(),
};

static readonly args = {
Expand All @@ -25,28 +25,30 @@ export default class Inspect extends Command {

async run() {
const { args, flags } = await this.parse(Inspect);

let filePath = args['spec-file'];

const proxyHost = flags['proxyHost'];

const proxyPort = flags['proxyPort'];

if (proxyHost && proxyPort) {
const proxyUrl = `http://${proxyHost}:${proxyPort}`;
filePath = `${filePath}+${proxyUrl}`; // Update filePath with proxyUrl
filePath = `${filePath}+${proxyUrl}`;
}

try {
this.specFile = await load(filePath);
} catch (err: any) {
}
catch (err: any) {
if (err.message.includes('Failed to download')) {
throw new Error('Proxy Connection Error: Unable to establish a connection to the proxy check hostName or PortNumber.');
} else {
this.error(
new ValidationError({
type: 'invalid-file',
filepath: filePath,
})
);
}
else {
this.error(new ValidationError({type: 'invalid-file',filepath: filePath}));
}
}
let { document } = await parse(this, this.specFile);
const { document } = await parse(this, this.specFile);
const channels = await numberOfChannels(document);
const servers = await numberOfServers(document);
const components = await numberOfComponents(document);
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils/numberOfComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AsyncAPIDocumentInterface } from '@asyncapi/parser/cjs/models';
export async function numberOfComponents(document: AsyncAPIDocumentInterface | undefined) {
let countComponents = 0;
if (document?.components().json()) {
countComponents = document?.components().json.length;
countComponents = Object.keys(document?.components().json()).length;
}
return countComponents;
}

0 comments on commit 8dabafe

Please sign in to comment.