|
1 | 1 | #typed-openapi |
2 | 2 |
|
| 3 | +##2.0.0 |
| 4 | + |
| 5 | +###Major Changes |
| 6 | + |
| 7 | +- 8f1eaa5: Add comprehensive type-safe error handling and configurable status codes |
| 8 | + |
| 9 | +-**Type-safe error handling**: Added discriminated unions for API responses with`SafeApiResponse` and |
| 10 | +`InferResponseByStatus` types that distinguish between success and error responses based on HTTP status codes |
| 11 | +-**TypedResponseError class**: Introduced`TypedResponseError` that extends the native Error class to include typed |
| 12 | + response data for easier error handling |
| 13 | +- Expose`successStatusCodes` and`errorStatusCodes` arrays on the generated API client instance for runtime access |
| 14 | +-**withResponse parameter**: Enhanced API clients to optionally return both the parsed data and the original Response |
| 15 | + object for advanced use cases |
| 16 | +-**throwOnStatusError option**: Added`throwOnStatusError` option to automatically throw`TypedResponseError` for |
| 17 | + error status codes, simplifying error handling in async/await patterns, defaulting to`true` (unless`withResponse` |
| 18 | + is set to true) |
| 19 | +-**TanStack Query integration**: The above features are fully integrated into the TanStack Query client generator: |
| 20 | +- Advanced mutation options supporting`withResponse` and`selectFn` parameters |
| 21 | +- Automatic error type inference based on OpenAPI error schemas instead of generic Error type |
| 22 | +- Type-safe error handling with discriminated unions for mutations |
| 23 | +- Response-like error objects that extend Response with additional`data` property for consistency |
| 24 | +-**Configurable status codes**: Made success and error status codes fully configurable: |
| 25 | +- New`--success-status-codes` and`--error-status-codes` CLI options |
| 26 | +-`GeneratorOptions` now accepts`successStatusCodes` and`errorStatusCodes` arrays |
| 27 | +- Default error status codes cover comprehensive 4xx and 5xx ranges |
| 28 | +-**Enhanced CLI options**: Added new command-line options for better control: |
| 29 | +-`--include-client` to control whether to generate API client types and implementation |
| 30 | +-`--include-client=false` to only generate the schemas and endpoints |
| 31 | +-**Enhanced types**: expose`SuccessStatusCode` /`ErrorStatusCode` type and their matching runtime typed arrays |
| 32 | +-**Comprehensive documentation**: Added detailed examples and guides for error handling patterns |
| 33 | + |
| 34 | + This release significantly improves the type safety and flexibility of generated API clients, especially for error |
| 35 | + handling scenarios. |
| 36 | + |
3 | 37 | ##1.5.1 |
4 | 38 |
|
5 | 39 | ###Patch Changes |
|