@let-aurn/swagger-client 0.3.0 → 0.3.1

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 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,7 +4,7 @@ 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, Provider, Type } from '@angular/core';
7
+ import { EnvironmentProviders, Inject, Injectable, InjectionToken, makeEnvironmentProviders, Type } from '@angular/core';
8
8
  import { Observable } from 'rxjs';
9
9
  import type {
10
10
  AnyApiEndpoint,
@@ -130,17 +130,17 @@ export class SwaggerClientService {
130
130
  }
131
131
 
132
132
  /**
133
- * Provides the generated Angular swagger client and its HTTP adapter.
133
+ * Provides the generated Angular swagger client and its HTTP adapter in an environment injector.
134
134
  *
135
135
  * @param config The swagger client runtime configuration.
136
- * @returns Angular providers for the generated client.
136
+ * @returns Environment providers for application or route configuration.
137
137
  */
138
- export function provideSwaggerClient(config: SwaggerClientConfig): Provider[] {
139
- return [
138
+ export function provideSwaggerClient(config: SwaggerClientConfig): EnvironmentProviders {
139
+ return makeEnvironmentProviders([
140
140
  { provide: SWAGGER_CLIENT_CONFIG, useValue: config },
141
141
  { provide: SWAGGER_HTTP_CLIENT, useClass: config.httpClient ?? AngularSwaggerHttpClient },
142
142
  SwaggerClientService
143
- ];
143
+ ]);
144
144
  }
145
145
 
146
146
  function buildRequest<TEndpoint extends AnyApiEndpoint>(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@let-aurn/swagger-client",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Generate typed Angular and React clients from OpenAPI JSON files.",
5
5
  "type": "module",
6
6
  "bin": {