Skip to content

Commit 9d3fe0d

Browse files
committed
chore: changeset
1 parent 57217a8 commit 9d3fe0d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.changeset/true-lemons-think.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
"typed-openapi": minor
3+
---
4+
5+
Add comprehensive type-safe error handling and configurable status codes
6+
7+
- **Type-safe error handling**: Added discriminated unions for API responses with `SafeApiResponse` and `TypedApiResponse` types that distinguish between success and error responses based on HTTP status codes
8+
- **withResponse parameter**: Enhanced API clients to optionally return both the parsed data and the original Response object for advanced use cases
9+
- **TanStack Query integration**: Added complete TanStack Query client generation with:
10+
- Advanced mutation options supporting `withResponse` and `selectFn` parameters
11+
- Automatic error type inference based on OpenAPI error schemas instead of generic Error type
12+
- Type-safe error handling with discriminated unions for mutations
13+
- **Configurable status codes**: Made success and error status codes fully configurable:
14+
- New `--success-status-codes` and `--error-status-codes` CLI options
15+
- `GeneratorOptions` now accepts `successStatusCodes` and `errorStatusCodes` arrays
16+
- Default error status codes cover comprehensive 4xx and 5xx ranges
17+
- **Enhanced CLI options**: Added new command-line options for better control:
18+
- `--include-client` to control whether to generate API client types and implementation
19+
- `--include-client=false` to only generate the schemas and endpoints
20+
- **Enhanced types**: Renamed `StatusCode` to `TStatusCode` and added reusable `ErrorStatusCode` type
21+
- **Comprehensive documentation**: Added detailed examples and guides for error handling patterns
22+
23+
This release significantly improves the type safety and flexibility of generated API clients, especially for error handling scenarios.

0 commit comments

Comments
 (0)