openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Client instance duplicate identifier

Open bkdiehl opened this issue 1 year ago • 1 comments

Description

When generating a client instance, I'm running into a duplicate identifier

export class AuthClient {
  public readonly model: ModelService;
  public readonly request: RequestService;

  public readonly request: BaseHttpRequest;

  constructor(
    config?: Partial<OpenAPIConfig>,
    HttpRequest: HttpRequestConstructor = FetchHttpRequest
  ) {
    this.request = new HttpRequest({
      BASE: config?.BASE ?? '',
      VERSION: config?.VERSION ?? '2',
      WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
      CREDENTIALS: config?.CREDENTIALS ?? 'include',
      TOKEN: config?.TOKEN,
      USERNAME: config?.USERNAME,
      PASSWORD: config?.PASSWORD,
      HEADERS: config?.HEADERS,
      ENCODE_PATH: config?.ENCODE_PATH,
      interceptors: {
        request: config?.interceptors?.request ?? new Interceptors(),
        response: config?.interceptors?.response ?? new Interceptors(),
      },
    });

    this.model = new ModelService(this.request);
    this.request = new RequestService(this.request);
  }
}

public readonly request: BaseHttpRequest; collides with the generated public readonly request: RequestService; I'm not sure what naming conventions you have planned, but it would be great if naming conventions for either the generated services or the baseHttpRequest had no chance of collisions.

OpenAPI specification (optional)

No response

Configuration

export default defineConfig({
  name: 'AuthClient',
});

System information (optional)

No response

bkdiehl avatar Apr 30 '24 18:04 bkdiehl

Hey @bkdiehl, will you able to migrate to the new Fetch API client? You can view a demo to see it in action. It shouldn't be suffering from this issue.

mrlubos avatar May 21 '24 12:05 mrlubos