You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Like this library?** Give us a star or a like!
5
11
6
-
This codebase houses the dart/flutter implementations of the openapi client sdk code generation libraries.
12
+
---
7
13
8
-
## TOC
14
+
## ⚠️ Java Requirement
9
15
10
-
-[Introduction](#introduction)
11
-
-[Usage](#usage)
12
-
-[NextGen](#next-generation)
13
-
-[Features & Bugs](#features-and-bugs)
16
+
> **Java is required to use this library.**
17
+
> The OpenAPI Generator CLI is a Java application.
18
+
> Please ensure you have Java (version 8 or higher) installed and available in your system PATH.
19
+
> You can check your Java installation with:
20
+
>
21
+
> ```sh
22
+
> java -version
23
+
>```
24
+
>
25
+
> If you do not have Java installed, download it from [Adoptium](https://adoptium.net/) or [Oracle](https://www.oracle.com/java/technologies/downloads/).
14
26
15
-
## Introduction
27
+
---
16
28
17
-
With this project, you can generate client libraries from your openapi specification right in your
18
-
flutter/dart projects (see example). This library was inspired by the npm
| openapi-generator | Dev dependency for generating openapi client sdk via dart source gen [see here for usage](https://pub.dev/packages/openapi_generator)|[](https://pub.dev/packages/openapi_generator)|
28
-
| openapi-generator-annotations | Annotations for annotating dart class with instructions for generating openapi client sdk [see here for usage](https://pub.dev/packages/openapi_generator_annotations)|[](https://pub.dev/packages/openapi_generator)|
29
-
| openapi-generator-cli | CLI only generator. [see here for usage](https://pub.dev/packages/openapi_generator_cli)|[](https://pub.dev/packages/openapi_generator_cli)|
51
+
---
30
52
31
-
## Usage
53
+
## Overview
32
54
33
-
Include [openapi-generator-annotations](https://pub.dev/packages/openapi_generator_annotations) as a dependency in the
34
-
dependencies section of your pubspec.yaml file :
55
+
This repository provides Dart/Flutter libraries for generating OpenAPI client SDKs directly from your OpenAPI specification. Inspired by [Openapi Generator Cli (npm)](https://www.npmjs.com/package/@openapitools/openapi-generator-cli), it enables seamless integration into Dart and Flutter projects.
35
56
36
-
```yaml
37
-
dependencies:
38
-
openapi_generator_annotations: ^[latest-version]
39
-
```
57
+
### Libraries
40
58
41
-
For testing out the beta features in openapi generator, use the beta branch like below. This is not recommended for
| openapi-generator | Dev dependency for generating OpenAPI client SDK via Dart source gen ([usage](https://pub.dev/packages/openapi_generator)) | [](https://pub.dev/packages/openapi_generator) |
Check out the known issues article here [Known Issues](openapi-generator-annotations/README.md#known-issues)
159
+
## Advanced Configuration
140
160
141
-
## Contributing
161
+
If you are having issues with the generated code, this is not an problem with this package and creating an issue here will not help solve it. Its best to [create the issue in the base OpenApi library](https://github.com/OpenAPITools/openapi-generator/issues) since this package is a wrapper around that library for ease of use with Flutter/dart.
142
162
143
-
All contributions are welcome. Please ensure to read through our [contributing guidelines](CONTRIBUTING.md) before
144
-
sending your PRs.
163
+
Below are some advanced configurations you may try.
145
164
146
-
## Features and bugs
165
+
-**Custom Templates:**
166
+
Use the `templateDirectory` parameter to specify a custom code generation template.
147
167
148
-
### Note:
168
+
-**Type & Import Mappings:**
169
+
Use `typeMappings` and `importMappings` to control how OpenAPI types and models are mapped in Dart.
149
170
150
-
Some issues may originate from the base OpenAPI Generator library rather than this Dart/Flutter wrapper. This library provides Dart-specific configuration and tools, but the actual code generation is handled by the underlying OpenAPI Generator.
171
+
-**Reserved Words:**
172
+
Use `reservedWordsMappings` to avoid conflicts with Dart reserved words.
151
173
152
-
If you encounter problems with the generated code (such as incorrect imports, unexpected code structure, or type mismatches), these are often caused by the base generator, not this wrapper. You may be able to resolve some of these issues by customizing the @Openapi() annotation options.
-**template**: Allows you to specify a custom code generation template, helping fix issues related to the structure or style of the generated code.
190
+
---
155
191
156
-
-**importMappings**: Lets you map OpenAPI model names to custom Dart imports, which helps fix problems with incorrect or missing import statements in the generated code.
192
+
## Troubleshooting
157
193
158
-
-**typeMappings**: Allows you to map OpenAPI schema types to your own Dart types, which is useful for resolving issues where generated classes don’t match your project’s types or when you need to substitute types for better compatibility.
194
+
### Common Issues
159
195
160
-
If the issue is specifically with the generated code, please open your issue in the original OpenAPI Generator repository.
196
+
-**Dependency Conflicts:**
197
+
Use `dependency_overrides` in the generated package's `pubspec.yaml` and add `pubspec.yaml` to `.openapi-generator-ignore` to prevent overwrites.
161
198
162
-
If you’re unsure where the problem comes from, feel free to open an issue here—we’ll help point you in the right direction.
199
+
-**Incorrect Generated Code:**
200
+
- Fix your OpenAPI spec (preferred).
201
+
- Manually edit the generated code and add the files to `.openapi-generator-ignore` to prevent them from being overwritten.
163
202
164
-
Please file feature requests and bugs at the [issue tracker][tracker].
0 commit comments