@@ -11,7 +11,7 @@ To be used together with [openapi-generator-annotations](https://pub.dev/package
11
11
12
12
1 . ** Java** : You must have java installed on your system for this library to work. if you are a developer, chances aare
13
13
you already. Walking you through how to install Java is beyond the scope of this project.
14
- 2 . ** Internet** : _ duh!!!_ Just to download the openapi jar initially. Once it is cached, you are good to go.
14
+ 2 . ** Internet Connection ** : _ duh!!!_ Just to download the openapi jar initially. Once it is cached, you are good to go.
15
15
16
16
## Usage
17
17
@@ -31,16 +31,20 @@ dev_dependencies:
31
31
openapi_generator : ^latest
32
32
` ` `
33
33
34
- Annotate a dart class with @Openapi() annotation
34
+ Annotate any dart class with @Openapi() annotation
35
35
36
36
` ` ` dart
37
37
@Openapi(
38
- additionalProperties :
39
- AdditionalProperties(pubName : ' petstore_api' , pubAuthor: 'Johnny dep'),
40
- inputSpecFile : ' example/openapi-spec.yaml' ,
41
- generatorName : Generator.dart,
42
- outputDirectory : ' api/petstore_api' )
43
- class Example extends OpenapiGeneratorConfig {}
38
+ additionalProperties :
39
+ DioProperties(pubName : ' petstore_api' , pubAuthor: 'Johnny dep..'),
40
+ inputSpec :
41
+ RemoteSpec(path : ' https://petstore3.swagger.io/api/v3/openapi.json' ),
42
+ typeMappings : {'Pet': 'ExamplePet'},
43
+ generatorName : Generator.dio,
44
+ runSourceGenOnOutput : true,
45
+ outputDirectory : ' api/petstore_api' ,
46
+ )
47
+ class Example {}
44
48
```
45
49
46
50
Run command below to generate open api client sdk from spec file specified in annotation.
@@ -51,40 +55,52 @@ flutter pub run build_runner build --delete-conflicting-outputs
51
55
52
56
The api sdk will be generated in the folder specified in the annotation. See examples for more details
53
57
54
- ## Next Generation
55
-
56
- As of version 5.0 of this library, there is some new functionality that has been added to the generator. This version
58
+ As of version 6.0 of this library, there is some new functionality that has been added to the generator. This version
57
59
will have the ability to:
58
60
59
- - cache changes in the openapi spec
60
- - Rerun when there ares difference in the cached copy and current copy
61
- - Pull from a remote source and cache that.
62
- - ** Note** : This means that your cache could be potentially stale. But in that case this flow will still pull the
63
- latest and run.
64
- - While this is a possible usage, if you are actively developing your spec it is preferred you provide a local copy.
65
- - Skip generation based off:
66
- - Flags
67
- - No difference between the cache and local
68
- - And all the functionality provided previously.
61
+ - ` skipIfSpecUnchanged ` : Set to ` false ` if you want the library to generate the client SDK each time, even without
62
+ changes in the OpenAPI spec. Defaults to ` true ` .
63
+ - ` forceAlwaysRun ` (** Breaking Change** ): Forces ` build_runner ` to detect changes by marking the annotated file. May
64
+ cause merge conflicts in team environments, so it defaults to ` false ` .
69
65
70
- Your original workflow stay the same but there is a slight difference in the annotations.
66
+ ## Usage (pre 5.0.0 versions)
71
67
72
- New:
68
+ Include [ openapi-generator-annotations] ( https://pub.dev/packages/openapi_generator_annotations ) as a dependency in the
69
+ dependencies section of your pubspec.yaml file :
70
+
71
+ ``` yaml
72
+ dependencies :
73
+ openapi_generator_annotations : ^latest
74
+ ` ` `
75
+
76
+ Add [openapi-generator](https://pub.dev/packages/openapi_generator) in the dev dependencies section of your pubspec.yaml
77
+ file:
78
+
79
+ ` ` ` yaml
80
+ dev_dependencies :
81
+ openapi_generator : ^latest
82
+ ` ` `
83
+
84
+ Annotate any dart class with @Openapi() annotation
73
85
74
86
` ` ` dart
75
87
@Openapi(
76
- additionalProperties:
77
- DioProperties(pubName: 'petstore_api', pubAuthor: 'Johnny dep..'),
78
- inputSpec:
79
- RemoteSpec(path: 'https://petstore3.swagger.io/api/v3/openapi.json'),
80
- typeMappings: {'Pet': 'ExamplePet'},
81
- generatorName: Generator.dio,
82
- runSourceGenOnOutput: true,
83
- outputDirectory: 'api/petstore_api',
84
- )
85
- class Example {}
88
+ additionalProperties :
89
+ AdditionalProperties(pubName : ' petstore_api' , pubAuthor: 'Johnny dep'),
90
+ inputSpecFile : ' example/openapi-spec.yaml' ,
91
+ generatorName : Generator.dart,
92
+ outputDirectory : ' api/petstore_api' )
93
+ class Example extends OpenapiGeneratorConfig {}
94
+ ```
95
+
96
+ Run command below to generate open api client sdk from spec file specified in annotation.
97
+
98
+ ``` cmd
99
+ flutter pub run build_runner build --delete-conflicting-outputs
86
100
```
87
101
102
+ The api sdk will be generated in the folder specified in the annotation. See examples for more details
103
+
88
104
## Known Issues
89
105
90
106
### Dependency issues/conflicts
0 commit comments