@hey-api/openapi-ts 0.29.1 → 0.30.0

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
@@ -14,6 +14,7 @@
14
14
  - [Linting](#linting)
15
15
  - [Enums](#enums)
16
16
  - [Config API](#config-api)
17
+ - [Interceptors](#interceptors)
17
18
  - [Migrating](#migrating)
18
19
  - [Contributing](#contributing)
19
20
 
@@ -193,6 +194,30 @@ $ openapi-ts --help
193
194
  -h, --help display help for command
194
195
  ```
195
196
 
197
+ ## Interceptors
198
+
199
+ Interceptors (middleware) can be used to modify requests before they're sent or responses before they're returned to the rest of your application. Below is an example request interceptor
200
+
201
+ ```ts
202
+ OpenAPI.interceptors.request.use((request) => {
203
+ doSomethingWithRequest(request)
204
+ return request // <-- must return request
205
+ })
206
+ ```
207
+
208
+ and an example response interceptor
209
+
210
+ ```ts
211
+ OpenAPI.interceptors.response.use(async (response) => {
212
+ await doSomethingWithResponse(response) // async
213
+ return response // <-- must return response
214
+ })
215
+ ```
216
+
217
+ If you need to remove an interceptor, pass the same function to `OpenAPI.interceptors.request.eject()` or `OpenAPI.interceptors.response.eject()`.
218
+
219
+ > ⚠️ Angular client does not currently support request interceptors and async response interceptors.
220
+
196
221
  ## Migrating
197
222
 
198
223
  While we try to avoid breaking changes, sometimes it's unavoidable in order to offer you the latest features.