Skip to content

Commit 0df70e1

Browse files
committed
doc: Add next gen documentation to readme
1 parent 4e1898d commit 0df70e1

File tree

1 file changed

+69
-10
lines changed

1 file changed

+69
-10
lines changed

README.md

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
This codebase houses the dart/flutter implementations of the openapi client sdk code generation libraries.
66

7+
## TOC
8+
9+
- [Introduction](#introduction)
10+
- [Usage](#usage)
11+
- [NextGen](#next-generation)
12+
- [Features & Bugs](#features-and-bugs)
13+
14+
## Introduction
15+
716
With this project, you can generate openapi client sdk libraries for your openapi specification right in your
817
flutter/dart projects. (see example)
918

@@ -17,37 +26,42 @@ This repo contains the following dart libraries
1726
| openapi-generator-annotations | Annotations for annotating dart class with instructions for generating openapi sdk [see here for usage](https://pub.dev/packages/openapi_generator_annotations) | [![pub package](https://img.shields.io/pub/v/openapi_generator_annotations.svg)](https://pub.dev/packages/openapi_generator) |
1827
| openapi-generator-cli | Cli code openapi sdk generator for dart [see here for usage](https://pub.dev/packages/openapi_generator_cli) | [![pub package](https://img.shields.io/pub/v/openapi_generator_cli.svg)](https://pub.dev/packages/openapi_generator_cli) |
1928

20-
21-
2229
## Usage
2330

24-
Include [openapi-generator-annotations](https://pub.dev/packages/openapi_generator_annotations) as a dependency in the dependencies section of your pubspec.yaml file :
31+
Include [openapi-generator-annotations](https://pub.dev/packages/openapi_generator_annotations) as a dependency in the
32+
dependencies section of your pubspec.yaml file :
2533

2634
```yaml
2735
dependencies:
2836
openapi_generator_annotations: ^[latest-version]
2937
```
30-
For testing out the beta features in openapi generator, use the beta branch like below. This is not recommended for production builds
38+
39+
For testing out the beta features in openapi generator, use the beta branch like below. This is not recommended for
40+
production builds
41+
3142
```yaml
3243
dependencies:
33-
openapi_generator_annotations:
44+
openapi_generator_annotations:
3445
git:
3546
url: https://github.com/gibahjoe/openapi-generator-dart.git
3647
ref: beta
3748
path: openapi-generator-annotations
3849
```
3950
40-
41-
Add [openapi-generator](https://pub.dev/packages/openapi_generator) in the dev dependencies section of your pubspec.yaml file:
51+
Add [openapi-generator](https://pub.dev/packages/openapi_generator) in the dev dependencies section of your pubspec.yaml
52+
file:
4253
4354
```yaml
4455
dev_dependencies:
4556
openapi_generator: ^[latest version]
4657
```
47-
For testing out the beta features in openapi generator, use the beta branch like below. This is not recommended for production builds
58+
59+
For testing out the beta features in openapi generator, use the beta branch like below. This is not recommended for
60+
production builds
61+
4862
```yaml
4963
dev_dependencies:
50-
openapi_generator:
64+
openapi_generator:
5165
git:
5266
url: https://github.com/gibahjoe/openapi-generator-dart.git
5367
ref: beta
@@ -66,17 +80,62 @@ Annotate a dart class with @Openapi() annotation
6680
class Example extends OpenapiGeneratorConfig {}
6781
```
6882

69-
Run
83+
Run
84+
7085
```shell
7186
dart run build_runner build --delete-conflicting-outputs
7287
```
88+
7389
or
90+
7491
```shell
7592
flutter pub run build_runner build --delete-conflicting-outputs
7693
```
94+
7795
to generate open api client sdk from spec file specified in annotation.
7896
The api sdk will be generated in the folder specified in the annotation. See examples for more details
7997

98+
## Next Generation
99+
100+
There is some new functionality slated to be added to the generator. This version will have the ability to:
101+
102+
- cache changes in the OAS spec
103+
- Rerun when there ares difference in the cached copy and current copy
104+
- Pull from a remote source and cache that.
105+
- **Note**: This means that your cache could be potentially stale. But in that case this flow will still pull the
106+
latest and run.
107+
- While this is a possible usage, if you are actively developing your spec it is preferred you provide a local copy.
108+
- Skip generation based off:
109+
- Flags
110+
- No difference between the cache and local
111+
- And all the functionality provided previously.
112+
113+
Your original workflow stay the same but there is a slight difference in the annotations.
114+
115+
New:
116+
117+
```dart
118+
@Openapi(
119+
additionalProperties:
120+
AdditionalProperties(pubName: 'petstore_api', pubAuthor: 'Johnny dep'),
121+
inputSpecFile: 'example/openapi-spec.yaml',
122+
generatorName: Generator.dart,
123+
outputDirectory: 'api/petstore_api',
124+
cachePath: 'some/preferred/directory/cache.json',
125+
useNextGen: true
126+
)
127+
class Example extends OpenapiGeneratorConfig {}
128+
```
129+
130+
**IMPORTANT** With the new changes comes 2 new annotation properties:
131+
132+
- useNextGen (boolean)
133+
- Default: `false`
134+
- cachePath (String)
135+
- Default: `.dart_tool/openapi-generator-cache.json`
136+
- Must be a path to a `json` file.
137+
- Can only be set when `useNextGen` is `true`
138+
80139
## Features and bugs
81140

82141
Please file feature requests and bugs at the [issue tracker][tracker].

0 commit comments

Comments
 (0)