OpenAPITools / OpenAPITools/openapi-generator

[REQ][typescript-angular] Custom options object

Open
#7,737 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Client: TypeScript Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Very often in large projects, for example, on angular, which load a huge amount of different data, it is required to display a spinner while loading this data. Managing loaders manually, in my opinion, is very inefficient and inconvenient, especially when you need to handle data loading errors for specific elements loading data without affecting other loaders. About six months ago, I forked the generator and added a loaderKey field to the options of the generated methods, which allows identifying a specific loader and handling it very conveniently in one place (for example, the http interceptor in Angular). It has shown high efficiency and convenience. It seems to me that support for adding custom properties to the options parameter or replacing it could be great to diversify the functional for identifying requests.

Default:

options?: {httpHeaderAccept?: 'application/json' }

Example:

public getRoleList(sysname?: string, creationdateStart?: Date, creationdateEnd?: Date, offset?: number, limit?: number, orderBy?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', loaderKey?: 'default' | string}): Observable<Array<RoleDto>>;
public getRoleList(sysname?: string, creationdateStart?: Date, creationdateEnd?: Date, offset?: number, limit?: number, orderBy?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', loaderKey?: 'default' | string}): Observable<HttpResponse<Array<RoleDto>>>;
public getRoleList(sysname?: string, creationdateStart?: Date, creationdateEnd?: Date, offset?: number, limit?: number, orderBy?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', loaderKey?: 'default' | string}): Observable<HttpEvent<Array<RoleDto>>>;
public getRoleList(sysname?: string, creationdateStart?: Date, creationdateEnd?: Date, offset?: number, limit?: number, orderBy?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', loaderKey?: 'default' | string}): Observable<any> {
...
}

Describe the solution you'd like

Example:

options?: {httpHeaderAccept?: 'application/json', loaderKey?: 'default' | string}

Add the ability to customize the options parameter to the configuration, perhaps like this:

config.json

{
    ...,
    options: {httpHeaderAccept?: 'application/json', loaderKey?: 'default' | string}
}

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 with the typescript-angular generator and its configuration handling, then compare the generated options parameter shown in the issue with the proposed config.json shape. Determine how custom option properties or replacement should be represented and propagated to generated methods. Done means the configuration can produce the requested loaderKey option without breaking existing options behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, openapi, typescript
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.