@sdk-it/dart 0.17.0 → 0.18.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.
Files changed (2) hide show
  1. package/README.md +82 -0
  2. package/package.json +5 -3
package/README.md CHANGED
@@ -0,0 +1,82 @@
1
+ # @sdk-it/dart
2
+
3
+ A Dart SDK generator that converts OpenAPI specifications into type-safe Dart client libraries.
4
+
5
+ ## Description
6
+
7
+ This package generates Dart client code from OpenAPI specifications. The generated SDK includes:
8
+
9
+ - Dart classes for API models
10
+ - API client classes for each tag/group
11
+ - Request and response handling
12
+ - Type-safe method signatures
13
+
14
+ ## Installation
15
+
16
+ Add the generated SDK to your Dart or Flutter project. The generator will create a `pubspec.yaml` with required dependencies (such as `http` and `mime`).
17
+
18
+ ## Usage
19
+
20
+ <details>
21
+ <summary>Generate a Dart SDK (OpenStatus Example)</summary>
22
+
23
+ > **Note:** This uses the [OpenStatus](https://www.openstatus.dev/) public OpenAPI spec as an example.
24
+
25
+ ```bash
26
+ npx @sdk-it/cli@latest dart \
27
+ --spec https://api.openstatus.dev/v1/openapi \
28
+ --output ./openstatus \
29
+ --name OpenStatus \
30
+ --mode full
31
+ ```
32
+
33
+ This command creates a Dart package in the `./openstatus` directory.
34
+
35
+ </details>
36
+
37
+ ### Add the SDK to Your Project
38
+
39
+ Add the generated SDK as a dependency in your `pubspec.yaml`:
40
+
41
+ ```yaml
42
+ dependencies:
43
+ openstatus_sdk:
44
+ path: ./openstatus
45
+ ```
46
+
47
+ Run `dart pub get` or `flutter pub get` to install dependencies.
48
+
49
+ ### Create and Configure the Client
50
+
51
+ ```dart
52
+ import 'package:openstatus_sdk/package.dart';
53
+
54
+ final openstatus = OpenStatus(Options(baseUrl: 'https://api.openstatus.dev/v1/'));
55
+ ```
56
+
57
+ ### Make an API Request
58
+
59
+ ```dart
60
+ final status = await openstatus.statusReport.getStatusReport();
61
+ if (status != null) {
62
+ print('Status: \\${status.summary}');
63
+ } else {
64
+ print('Request failed');
65
+ }
66
+ ```
67
+
68
+ ### Format Generated Code
69
+
70
+ The generator can format the output using `dart format` automatically. You can also run it manually:
71
+
72
+ ```bash
73
+ dart format ./openstatus
74
+ ```
75
+
76
+ ## Notes
77
+
78
+ - The Dart SDK generator creates a package structure compatible with Dart and Flutter projects.
79
+ - The generated code uses the `http` package for HTTP requests.
80
+ - Each API group (tag) is mapped to a Dart client class.
81
+ - The generator supports OpenAPI 3.0 and 3.1 specifications.
82
+ - For advanced usage, see the [TypeScript package documentation](../typescript/README.md) for general SDK-IT concepts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdk-it/dart",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -22,9 +22,11 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "openapi3-ts": "4.4.0",
25
- "@sdk-it/core": "0.17.0",
25
+ "@sdk-it/core": "0.18.0",
26
26
  "lodash-es": "^4.17.21",
27
27
  "stringcase": "^4.3.1",
28
- "@sdk-it/spec": "0.17.0"
28
+ "@sdk-it/spec": "0.18.0",
29
+ "fast-content-type-parse": "^3.0.0",
30
+ "yaml": "^2.7.0"
29
31
  }
30
32
  }