testing library
Test utilities for degenerate-generated API clients.
import 'package:degenerate_runtime/testing.dart';
Classes
- ApiClient
- The contract any HTTP client must satisfy.
- ApiConfig
- Configuration for the generated API classes.
-
ApiException<
T, E> - Network-level failure (DNS, timeout, connection refused).
- ApiMultipartField
- A single field in a multipart/form-data request.
- ApiMultipartFileField
- A binary file field in a multipart/form-data request.
- ApiMultipartTextField
- A text field in a multipart/form-data request.
- ApiOAuthFlow
- An OAuth 2.0 flow configuration.
-
ApiParseException<
T, E> - The server returned a response but it could not be deserialized.
- ApiQueryParameter
- A single query parameter with encoding options.
- ApiRequest
- An outgoing API request.
- ApiResponse
- A raw API response before deserialization.
-
ApiResult<
T, E> - The result of an API operation.
- ApiSecurityRequirement
- A security requirement that maps scheme names to required scopes.
- ApiSecurityScheme
- A security scheme defined in an OpenAPI spec.
-
ApiSuccess<
T, E> - A successful API response containing deserialized data.
- AuthInterceptor
- Middleware that adds an Authorization header and optionally refreshes the token on 401 responses.
- CancelToken
- A token that can be used to cancel one or more API requests.
- Interceptor
- Middleware that can inspect/modify requests and responses.
- LoggingInterceptor
- Middleware that logs requests and responses.
-
OneOf2<
A, B> - Typed union of 2 variants.
-
OneOf3<
A, B, C> - Typed union of 3 variants.
-
OneOf4<
A, B, C, D> - Typed union of 4 variants.
-
OneOf5<
A, B, C, D, E> - Typed union of 5 variants.
-
OneOf6<
A, B, C, D, E, F> - Typed union of 6 variants.
-
OneOf7<
A, B, C, D, E, F, G> - Typed union of 7 variants.
-
OneOf8<
A, B, C, D, E, F, G, H> - Typed union of 8 variants.
-
OneOf9<
A, B, C, D, E, F, G, H, I> - Typed union of 9 variants.
- RecordingClient
- A test ApiClient that records requests and returns canned responses.
- RequestOptions
- Per-request overrides for timeout, headers, and cancellation.
- RetryInterceptor
- Middleware that retries failed requests with exponential backoff.
- SseEvent
- A parsed Server-Sent Event.
- StreamedApiResponse
- A streaming API response where the body is delivered as a byte stream.
Enums
- ApiKeyLocation
- Where an API key is sent in the request.
- ApiOAuthFlowType
- The type of OAuth 2.0 flow.
- ApiSecuritySchemeType
- The type of security scheme defined in an OpenAPI spec.
Mixins
- ApiExecutor
- Shared execution logic for generated API classes.
Constants
- immutable → const Immutable
- Annotation on an immutable class.
Functions
-
buildInterceptorChain(
{required List< Interceptor> interceptors, required Handler terminal}) → Handler - Build a middleware chain from a list of interceptors and a terminal handler.
-
listEquals<
T> (List< T> ? a, List<T> ? b) → bool - Element-wise equality check for lists.
-
mapEquals<
K, V> (Map< K, V> ? a, Map<K, V> ? b) → bool - Entry-wise equality check for maps.
-
parseJsonlStream(
Stream< List< byteStream) → Stream<int> >String> - Parses a byte stream of newline-delimited JSON (JSONL/NDJSON) into individual JSON strings, one per non-empty line.
-
parseSseStream(
Stream< List< byteStream, {String? doneSignal = '[DONE]'}) → Stream<int> >SseEvent> - Parse a byte stream of Server-Sent Events into SseEvents.
Typedefs
-
Handler
= Future<
ApiResponse> Function(ApiRequest request) - A function that processes a request and returns a response.
- RetryRandom = double Function()
- A function that returns a random double in the range [0, 1).
-
RetrySleep
= Future<
void> Function(Duration delay) -
A function that delays execution for the given
delayduration.
Exceptions / Errors
-
ApiError<
T, E> - A non-2xx API response, optionally containing a typed error body.
- ApiStreamError
- Thrown when a streaming request receives a non-2xx response.
- CancelledException
- Thrown when a request is cancelled via CancelToken.