hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client
https://heyapi.vercel.app
MIT License
685 stars 52 forks source link

Client instance duplicate identifier #517

Open bkdiehl opened 2 months ago

bkdiehl commented 2 months ago

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

mrlubos commented 1 month ago

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.