Skip to content

Commit

Permalink
fixup! fix(angular): add request overloads based on observe property
Browse files Browse the repository at this point in the history
  • Loading branch information
QuietNatu committed Sep 19, 2024
1 parent 6e3b1c5 commit a76c24d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ANGULAR_DEPENDENCIES: GeneratorDependency[] = [
{ name: 'HttpHeaders' },
{ name: 'HttpParams' },
{ name: 'HttpContext' },
{ name: 'HttpResponse' },
{ name: 'HttpResponse', alias: 'AngularHttpResponse' }, // alias to prevent naming conflict with msw
{ name: 'HttpEvent' },
],
dependency: '@angular/common/http',
Expand Down Expand Up @@ -217,7 +217,7 @@ const generateImplementation = (
const propsDefinition = toObjectString(props, 'definition');
const overloads = isRequestOptions
? `${operationName}<TData = ${dataType}>(\n ${propsDefinition} options?: Omit<HttpClientOptions, 'observe'> & { observe?: 'body' }\n ): Observable<TData>;
${operationName}<TData = ${dataType}>(\n ${propsDefinition} options?: Omit<HttpClientOptions, 'observe'> & { observe?: 'response' }\n ): Observable<HttpResponse<TData>>;
${operationName}<TData = ${dataType}>(\n ${propsDefinition} options?: Omit<HttpClientOptions, 'observe'> & { observe?: 'response' }\n ): Observable<AngularHttpResponse<TData>>;
${operationName}<TData = ${dataType}>(\n ${propsDefinition} options?: Omit<HttpClientOptions, 'observe'> & { observe?: 'events' }\n ): Observable<HttpEvent<TData>>;`
: '';

Expand Down
6 changes: 3 additions & 3 deletions samples/angular-app/src/api/endpoints/pets/pets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
HttpEvent,
HttpHeaders,
HttpParams,
HttpResponse,
HttpResponse as AngularHttpResponse,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
Expand Down Expand Up @@ -62,7 +62,7 @@ export class PetsService {
createPetsBody: CreatePetsBody,
version?: number,
options?: Omit<HttpClientOptions, 'observe'> & { observe?: 'response' },
): Observable<HttpResponse<TData>>;
): Observable<AngularHttpResponse<TData>>;
createPets<TData = void>(
createPetsBody: CreatePetsBody,
version?: number,
Expand All @@ -87,7 +87,7 @@ export class PetsService {
petId: string,
version?: number,
options?: Omit<HttpClientOptions, 'observe'> & { observe?: 'response' },
): Observable<HttpResponse<TData>>;
): Observable<AngularHttpResponse<TData>>;
showPetById<TData = Pet>(
petId: string,
version?: number,
Expand Down

0 comments on commit a76c24d

Please sign in to comment.