Add ApiService Export to Generated Index File #381
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.
Add ApiService Export to Generated Index File
Fix issue #380
Summary
This pull request adds the
ApiService
class export to the main index file template, making it available for direct import from the generated API package root.Problem Statement
Previously, the
ApiService
class was not exported from the main index file (index.ts
), which meant developers had to import it from a specific nested path within the generated API package. This made the API less convenient to use and inconsistent with other core classes that were already being exported.Solution
Added an export statement for the
{{apiServiceClass}}
in thetemplates/index.handlebars
template file:This change ensures that when code is generated, the
ApiService
class will be available as a direct export from the package root, allowing for simpler imports like:Instead of having to use nested imports like:
Changes Made
Core Changes
templates/index.handlebars
: Added export line for{{apiServiceClass}}
from{{apiServiceFile}}
Test Updates
test/all-types.spec.ts
: Updated test to expect 6 exports instead of 5 in the generated index filetest/noModule.spec.ts
: Updated test to expect 4 exports instead of 3 for the no-module scenarioTesting
✅ All existing tests pass successfully
✅ Build process completes without errors
✅ Linting passes
✅ No breaking changes to existing functionality
The changes are backward compatible and only add new functionality without modifying existing behavior.
Impact
ApiService
directly importable from package rootGenerated Code Example
After this change, the generated
index.ts
file will include:This makes the API more intuitive and consistent with Angular conventions where service classes are typically exported from the main module index.