Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Dart SDK

This is the README that tungsten generates for the Dart target, shown for a small example API (Swagger's Petstore). Names change with your API; the structure does not.

These recorded examples retain their original generator and runtime versions. Their installation snippets name example generated packages; they are not a current registry installation recipe. See runtime distribution for the verified stable 0.1.2 package versions and matching source routes for the unreleased 0.1.3 candidate.

Dart SDK for openapi, generated by tungsten. It needs Dart 3.6 or later and the tungsten_runtime package (^0.1.3), which runs on dart:io (servers, command-line tools, Flutter on mobile and desktop; not the web).

Usage

import 'package:openapi_sdk/openapi_sdk.dart';
import 'package:tungsten_runtime/tungsten_runtime.dart';

Future<void> main() async {
  final client = OpenapiClient(ClientOptions(baseUrl: 'https://api.example.com'));
  final result = await client.pets.list();
  switch (result) {
    case Ok(:final value):
      print(value);
    case Err(:final error):
      print(error.remediation);
  }
}

Every method returns a Future<Result<T>>: Ok (value, raw, meta, verification) or Err (error: the diagnostic envelope with category, remediation, retryable, nextAction, ...). API and transport failures never throw.

Models are final classes with fromJson and toJson. A required member is T, a required member that may be null T?, an optional member T? (null is not sent), and an optional member that may be null a Patch<T>: Patch.absent(), Patch.nullValue() or Patch.of(value). Bytes are Uint8List.

Call options (CallOptions): idempotencyKey (generate it once per intent and reuse it on every retry), confirm (Confirm.yes for a destructive operation, or the confirmation token of its preview, the only way for an irreversible one), timeout.

Operations

MethodOperationSafety
client.pets.listopenapi.listPetsread_only
client.pets.createopenapi.createPetsmutating
client.pets.getopenapi.showPetByIdread_only

Custom code

lib/src/custom/extensions.dart is yours: tungsten creates it once and never overwrites it, and lib/openapi_sdk.dart exports it.