@let-aurn/swagger-client 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/generators/angular-client.js +8 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,7 +73,12 @@ error. This setting affects endpoint names only, not request URLs.
|
|
|
73
73
|
|
|
74
74
|
## Angular
|
|
75
75
|
|
|
76
|
+
Use `provideSwaggerClient` to register the client as
|
|
77
|
+
`EnvironmentProviders` without spreading a provider array:
|
|
78
|
+
|
|
76
79
|
```ts
|
|
80
|
+
import { provideSwaggerClient } from './api/generated/swagger-client';
|
|
81
|
+
|
|
77
82
|
bootstrapApplication(AppComponent, {
|
|
78
83
|
providers: [
|
|
79
84
|
provideHttpClient(),
|
|
@@ -84,6 +89,11 @@ bootstrapApplication(AppComponent, {
|
|
|
84
89
|
});
|
|
85
90
|
```
|
|
86
91
|
|
|
92
|
+
Starting with version `0.3.1`, `provideSwaggerClient(config)` returns
|
|
93
|
+
`EnvironmentProviders` for application or route configuration. Remove any spread
|
|
94
|
+
operator (`...`) when registering it. Version `0.3.0` retains the `Provider[]`
|
|
95
|
+
implementation.
|
|
96
|
+
|
|
87
97
|
### Custom HTTP adapters
|
|
88
98
|
|
|
89
99
|
Implement `SwaggerHttpClient` and pass the adapter class to `provideSwaggerClient`.
|
|
@@ -4,12 +4,13 @@ export function emitAngularClient(options = {}) {
|
|
|
4
4
|
/* eslint-disable */
|
|
5
5
|
// This file was generated by @let-aurn/swagger-client.
|
|
6
6
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
|
7
|
-
import { Inject, Injectable, InjectionToken,
|
|
7
|
+
import { EnvironmentProviders, Inject, Injectable, InjectionToken, makeEnvironmentProviders, Type } from '@angular/core';
|
|
8
8
|
import { Observable } from 'rxjs';
|
|
9
9
|
import type {
|
|
10
10
|
AnyApiEndpoint,
|
|
11
11
|
BodyVariablesOf,
|
|
12
12
|
HeaderVariablesOf,
|
|
13
|
+
HttpMethod,
|
|
13
14
|
PathVariablesOf,
|
|
14
15
|
QueryVariablesOf,
|
|
15
16
|
ResponseOf
|
|
@@ -27,7 +28,7 @@ export interface SwaggerClientConfig {
|
|
|
27
28
|
* Describes an HTTP request produced by the generated swagger client.
|
|
28
29
|
*/
|
|
29
30
|
export interface SwaggerHttpRequest {
|
|
30
|
-
method:
|
|
31
|
+
method: HttpMethod;
|
|
31
32
|
url: string;
|
|
32
33
|
headers?: Record<string, string>;
|
|
33
34
|
query?: Record<string, unknown>;
|
|
@@ -130,17 +131,17 @@ export class SwaggerClientService {
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
|
-
* Provides the generated Angular swagger client and its HTTP adapter.
|
|
134
|
+
* Provides the generated Angular swagger client and its HTTP adapter in an environment injector.
|
|
134
135
|
*
|
|
135
136
|
* @param config The swagger client runtime configuration.
|
|
136
|
-
* @returns
|
|
137
|
+
* @returns Environment providers for application or route configuration.
|
|
137
138
|
*/
|
|
138
|
-
export function provideSwaggerClient(config: SwaggerClientConfig):
|
|
139
|
-
return [
|
|
139
|
+
export function provideSwaggerClient(config: SwaggerClientConfig): EnvironmentProviders {
|
|
140
|
+
return makeEnvironmentProviders([
|
|
140
141
|
{ provide: SWAGGER_CLIENT_CONFIG, useValue: config },
|
|
141
142
|
{ provide: SWAGGER_HTTP_CLIENT, useClass: config.httpClient ?? AngularSwaggerHttpClient },
|
|
142
143
|
SwaggerClientService
|
|
143
|
-
];
|
|
144
|
+
]);
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
function buildRequest<TEndpoint extends AnyApiEndpoint>(
|