@@ -11,7 +11,7 @@ To be used together with [openapi-generator-annotations](https://pub.dev/package
1111
12121 . ** Java** : You must have java installed on your system for this library to work. if you are a developer, chances aare
1313 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.
1515
1616## Usage
1717
@@ -31,16 +31,20 @@ dev_dependencies:
3131 openapi_generator : ^latest
3232` ` `
3333
34- Annotate a dart class with @Openapi() annotation
34+ Annotate any dart class with @Openapi() annotation
3535
3636` ` ` dart
3737@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 {}
4448```
4549
4650Run 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
5155
5256The api sdk will be generated in the folder specified in the annotation. See examples for more details
5357
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
5759will have the ability to:
5860
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 ` .
6965
70- Your original workflow stay the same but there is a slight difference in the annotations.
66+ ## Usage (pre 5.0.0 versions)
7167
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
7385
7486` ` ` dart
7587@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
86100```
87101
102+ The api sdk will be generated in the folder specified in the annotation. See examples for more details
103+
88104## Known Issues
89105
90106### Dependency issues/conflicts
0 commit comments