swagger-api / swagger-api/swagger-codegen

typescript-angular2: Make the api suffix configurable

Open
#8,281 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

I'd be happy to have a look if I'm able to provide a pull request for this feature request, if nobody is already working on this. I had a look in the issue tracker but there was only a request for changing it from Api to Service and another unrelated request for adding a possiblity to define a suffix in the JAXRs generator.

Description

In earlier versions the generated service classes were suffixed with "Api". Recently this has changed to be "Service". While this adheres to angular standards it sometimes can cause collisions with existing services. For me it would make sense to use the api suffix because of multiple reasons.

  1. We avoid collisions. If I have a UserService in my client and somebody introduces a UserApi, suddenly I need to alias my imports in order to use both services in one place.

  2. Having the .api file extensions and the Api suffix in the class name, it makes it more clear to the developer, that this is not a normal service. If you work in our project then you know that apis are always generated.

Suggest a fix/enhancement

Introduce a configuration for typescript-angular2 which lets you specify a different suffix.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the typescript-angular2 generator and locate the templates or entry points that currently produce the Service suffix. Trace how generator configuration is passed through, then verify that a configurable suffix changes generated service class names without affecting other output.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.