fix: remove duplicate AsyncAPI specification loading in fromTemplate command#2071
Closed
chengyixu wants to merge 2 commits intoasyncapi:masterfrom
Closed
fix: remove duplicate AsyncAPI specification loading in fromTemplate command#2071chengyixu wants to merge 2 commits intoasyncapi:masterfrom
chengyixu wants to merge 2 commits intoasyncapi:masterfrom
Conversation
…capi#1995) - Update git-workflow.md link in DEVELOPMENT.md to correct path in asyncapi/community repo (moved from root to docs/010-contribution-guidelines/) - Remove outdated asyncapi.x86.exe link from Windows installation section as 32-bit executable is no longer included in releases Fixes asyncapi#1995
…command Closes asyncapi#2017 The `fromTemplate` command was loading the AsyncAPI specification twice: 1. `loadAsyncAPIInput(asyncapi)` — called to populate `this.specFile` for metrics/watch mode tracking (stored in `asyncapiInput`) 2. `load(asyncapi)` — called again immediately to get the `specification` variable passed to `generatorService.generate()` The result of the first load was assigned to `this.specFile` but never reused for generation, making the second `load()` call redundant. ## Changes - Wrap `loadAsyncAPIInput()` in the existing try/catch block so errors are handled with the proper `ValidationError` (identical to before) - Assign the single load result to `this.specFile` and reuse it as the `specification` argument to `generatorService.generate()` - Remove the now-unused `load` and `Specification` imports from the file This eliminates one full disk read + YAML parse per `generate fromTemplate` invocation, which is most noticeable for large specification files.
🦋 Changeset detectedLatest commit: 98b31bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #2017
Problem
The
generate fromTemplatecommand was loading the AsyncAPI specification file twice per invocation:loadAsyncAPIInput(asyncapi)— to populatethis.specFilefor metrics/watch modeload(asyncapi)— called immediately after to get aspecificationvariable for generationThe result of the first load (
asyncapiInput) was never reused for generation, so the second call was entirely redundant.Fix
loadAsyncAPIInput()call inside the existing try/catch block so invalid-file errors are still handled with the correctValidationError(same behaviour as before)specificationis now assigned to boththis.specFileand passed togeneratorService.generate()— one disk read / YAML parse instead of twoloadandSpecificationnamed imports from the fileImpact
Specificationobject returned byloadAsyncAPIInput()is the same as the one previously returned by the redundantload()callgenerate fromTemplaterun; most noticeable for large AsyncAPI documents