From 3f7799cd46d13e5cefb48af5a056ed152fea0c12 Mon Sep 17 00:00:00 2001 From: armorbreak001 Date: Tue, 14 Apr 2026 07:02:57 +0800 Subject: [PATCH] fix: remove duplicate AsyncAPI spec loading in fromTemplate --- .../cli/commands/generate/fromTemplate.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/apps/cli/commands/generate/fromTemplate.ts b/src/apps/cli/commands/generate/fromTemplate.ts index 32ed32f97..0de5d1a04 100644 --- a/src/apps/cli/commands/generate/fromTemplate.ts +++ b/src/apps/cli/commands/generate/fromTemplate.ts @@ -1,6 +1,6 @@ import { Args } from '@oclif/core'; import { BaseGeneratorCommand } from '@cli/internal/base/BaseGeneratorCommand'; -import { load, Specification } from '@models/SpecificationFile'; +import { Specification } from '@models/SpecificationFile'; import { ValidationError } from '@errors/validation-error'; import { GeneratorError } from '@errors/generator-error'; import { intro } from '@clack/prompts'; @@ -57,21 +57,12 @@ export default class Template extends BaseGeneratorCommand { // Apply proxy configuration using base class method asyncapi = this.applyProxyConfiguration(asyncapi, proxyHost, proxyPort); - const asyncapiInput = await this.loadAsyncAPIInput(asyncapi); - - this.specFile = asyncapiInput; - this.metricsMetadata.template = template; - - const watchTemplate = flags['watch']; - const genOption = this.buildGenOption(flags, parsedFlags); - let specification: Specification; try { - specification = await load(asyncapi); + specification = await this.loadAsyncAPIInput(asyncapi); } catch { return this.error( new ValidationError({ - type: 'invalid-file', filepath: asyncapi, }), @@ -79,6 +70,12 @@ export default class Template extends BaseGeneratorCommand { ); } + this.specFile = specification; + this.metricsMetadata.template = template; + + const watchTemplate = flags['watch']; + const genOption = this.buildGenOption(flags, parsedFlags); + const result = await this.generatorService.generate( specification, template,