platform/packages/openapi/README.md

38 lines
759 B
Markdown
Raw Normal View History

2024-08-04 23:18:17 +00:00
<p align="center"><a href="https://protevus.com" target="_blank"><img src="https://git.protevus.com/protevus/branding/raw/branch/main/protevus-logo-bg.png"></a></p>
2024-08-04 09:12:26 +00:00
2024-08-04 23:18:17 +00:00
# protevus_openapi
2024-08-04 09:12:26 +00:00
2024-08-04 23:18:17 +00:00
Reads and writes OpenAPI (Swagger) specifications.
2024-08-04 09:12:26 +00:00
2024-08-04 23:18:17 +00:00
conduit_open_api supports both v2 and v3 of the open_api specification.
2024-08-04 09:12:26 +00:00
2024-08-04 23:18:17 +00:00
To use v2 import:
2024-08-04 09:12:26 +00:00
2024-08-04 23:18:17 +00:00
```dart
import 'package:conduit_open_api/v2.dart';
```
To use v3 import:
2024-08-04 09:12:26 +00:00
2024-08-04 23:18:17 +00:00
```dart
import 'package:conduit_open_api/v3.dart';
```
2024-08-04 09:12:26 +00:00
2024-08-04 23:18:17 +00:00
You can us v2 and v3 within a single project.
2024-08-04 09:12:26 +00:00
2024-08-04 23:18:17 +00:00
Example
---
2024-08-04 09:12:26 +00:00
```dart
2024-08-04 23:18:17 +00:00
import 'package:conduit_open_api/v3.dart';
2024-08-04 09:12:26 +00:00
2024-08-04 23:18:17 +00:00
final file = File("test/specs/kubernetes.json");
final contents = await file.readAsString();
final doc = APIDocument.fromJSON(contents);
final output = JSON.encode(doc.asMap());
```
2024-08-04 09:12:26 +00:00