-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle tree-shakeable angular client case
- Loading branch information
Showing
21 changed files
with
3,176 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hey-api/openapi-ts': patch | ||
--- | ||
|
||
fix: handle tree-shakeable angular client case |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...napi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/core/ApiError.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { ApiRequestOptions } from './ApiRequestOptions'; | ||
import type { ApiResult } from './ApiResult'; | ||
|
||
export class ApiError extends Error { | ||
public readonly url: string; | ||
public readonly status: number; | ||
public readonly statusText: string; | ||
public readonly body: unknown; | ||
public readonly request: ApiRequestOptions; | ||
|
||
constructor(request: ApiRequestOptions, response: ApiResult, message: string) { | ||
super(message); | ||
|
||
this.name = 'ApiError'; | ||
this.url = response.url; | ||
this.status = response.status; | ||
this.statusText = response.statusText; | ||
this.body = response.body; | ||
this.request = request; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...est/__snapshots__/test/generated/v3_angular_tree_shakeable/core/ApiRequestOptions.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export type ApiRequestOptions<T = unknown> = { | ||
readonly body?: any; | ||
readonly cookies?: Record<string, unknown>; | ||
readonly errors?: Record<number | string, string>; | ||
readonly formData?: Record<string, unknown> | any[] | Blob | File; | ||
readonly headers?: Record<string, unknown>; | ||
readonly mediaType?: string; | ||
readonly method: | ||
| 'DELETE' | ||
| 'GET' | ||
| 'HEAD' | ||
| 'OPTIONS' | ||
| 'PATCH' | ||
| 'POST' | ||
| 'PUT'; | ||
readonly path?: Record<string, unknown>; | ||
readonly query?: Record<string, unknown>; | ||
readonly responseHeader?: string; | ||
readonly responseTransformer?: (data: unknown) => Promise<T>; | ||
readonly url: string; | ||
}; |
7 changes: 7 additions & 0 deletions
7
...api-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/core/ApiResult.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type ApiResult<TData = any> = { | ||
readonly body: TData; | ||
readonly ok: boolean; | ||
readonly status: number; | ||
readonly statusText: string; | ||
readonly url: string; | ||
}; |
55 changes: 55 additions & 0 deletions
55
...enapi-ts/test/__snapshots__/test/generated/v3_angular_tree_shakeable/core/OpenAPI.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type { HttpResponse } from '@angular/common/http'; | ||
import type { ApiRequestOptions } from './ApiRequestOptions'; | ||
|
||
type Headers = Record<string, string>; | ||
type Middleware<T> = (value: T) => T | Promise<T>; | ||
type Resolver<T> = (options: ApiRequestOptions<T>) => Promise<T>; | ||
|
||
export class Interceptors<T> { | ||
_fns: Middleware<T>[]; | ||
|
||
constructor() { | ||
this._fns = []; | ||
} | ||
|
||
eject(fn: Middleware<T>): void { | ||
const index = this._fns.indexOf(fn); | ||
if (index !== -1) { | ||
this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; | ||
} | ||
} | ||
|
||
use(fn: Middleware<T>): void { | ||
this._fns = [...this._fns, fn]; | ||
} | ||
} | ||
|
||
export type OpenAPIConfig = { | ||
BASE: string; | ||
CREDENTIALS: 'include' | 'omit' | 'same-origin'; | ||
ENCODE_PATH?: ((path: string) => string) | undefined; | ||
HEADERS?: Headers | Resolver<Headers> | undefined; | ||
PASSWORD?: string | Resolver<string> | undefined; | ||
TOKEN?: string | Resolver<string> | undefined; | ||
USERNAME?: string | Resolver<string> | undefined; | ||
VERSION: string; | ||
WITH_CREDENTIALS: boolean; | ||
interceptors: { | ||
response: Interceptors<HttpResponse<any>>; | ||
}; | ||
}; | ||
|
||
export const OpenAPI: OpenAPIConfig = { | ||
BASE: 'http://localhost:3000/base', | ||
CREDENTIALS: 'include', | ||
ENCODE_PATH: undefined, | ||
HEADERS: undefined, | ||
PASSWORD: undefined, | ||
TOKEN: undefined, | ||
USERNAME: undefined, | ||
VERSION: '1.0', | ||
WITH_CREDENTIALS: false, | ||
interceptors: { | ||
response: new Interceptors(), | ||
}, | ||
}; |
Oops, something went wrong.