It is necessary that the OpenAPI schema *swagger.json* be in the directory with the generator installed.
1. Call the following command to generate the client:
```bash openapi-generator-cli generate ```
1. The standard openapi-generator will only generate base code that uses libraries that rely on Dart's own code generation. Therefore, after the completion of the base generation, it is necessary to start the Dart generator:
```bash cd frontend_api flutter pub get flutter pub run build_runner build -d ```
As a result, we get a ready-made package, which will be located where you specified in the configuration file or console command. It remains to include it in *pubspec.yaml*:
Name: **Flutter**\ Id: Dart-Code.flutter\ Description: Flutter support and debugger for Visual Studio Code.\ Publisher: Dart Code\ VS Marketplace Link: <https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter>
Name: **Dart**\ Id: Dart-Code.dart-code\ Description: Dart language support and debugger for Visual Studio Code.\ Publisher: Dart Code\ VS Marketplace Link: <https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code>
Name: **#region folding for VS Code**\ Id: maptz.regionfolder\ Description: Provides folding for text wrapped with #region comments in VS Code.\ Publisher: maptz\ VS Marketplace Link: <https://marketplace.visualstudio.com/items?itemName=maptz.regionfolder>
First, install the latest version of the dart-dio generator as described in the documentation. Currently, it's 7.14.0.
After running the `openapi-generator-cli generate` command, you'll receive a pubspec.yaml file that differs from the one supplied with the mobile app. To use the correct pub package versions, you need to replace the generated pubspec.yaml file with the file from the mobile app's frontend_api folder before running the following commands:
After this operation, should we delete the lib/frontend_api folder and move the frontend_api folder in the main directory to the lib/frontend_api location?
openapi-generator-cli version : 7.14.0 openapi-generator-cli generate copied file from lib/frontend_api/pubspec.yaml to frontend_api/pubspec.yaml cd frontend_api frontend_api % flutter pub get frontend_api % dart run build_runner build -d
Building package executable... (1.5s) Built build_runner:build_runner. Compiling the build script.
log output for build_runner W ../../../../.pub-cache/hosted/pub.dev/source_gen-3.1.0/lib/src/constants/revive.dart:82:40: Error: The method 'getInvocation' isn't defined for the type 'DartObjectImpl'. - 'DartObjectImpl' is from 'package:analyzer/src/dart/constant/value.dart' ('../../../../.pub-cache/hosted/pub.dev/analyzer-8.4.1/lib/src/dart/constant/value.dart'). Try correcting the name to the name of an existing method, or defining a method named 'getInvocation'. final i = (objectas DartObjectImpl).getInvocation(); ^^^^^^^^^^^^^ E Failed to compile build script. Check builder definitions and generated script .dart_tool/build/entrypoint/build.dart.
Error: The method 'getInvocation' isn't defined for the type 'DartObjectImpl'. - 'DartObjectImpl' is from 'package:analyzer/src/dart/constant/value.dart'
Workaround: 1. First, run `dart pub downgrade analyzer`
It should look like the example below. Main problem is analyzer in version 8.4. you must downgrade to 8.2.