To generate an API client in Dart from an OpenApi.json
file, and use it in Flutter, follow these steps:
Related: see this gist for how to generate an
OpenApi.json
file on build from an ASP.NET 8 Minimal API project
- Create a new Flutter 3.10 (or later)
Application
project in Visual Studio Code: steps - Add the openapi_generator package to your project. Follow below steps instead of the instructions at pub.dev (at the time of writing they were out of date):
- Include
openapi_generator_annotations
in thedependencies
section of yourpubspec.yaml
file :dependencies: openapi_generator_annotations: ^4.10.0
- Include