Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 1.12 KB

README.md

File metadata and controls

29 lines (22 loc) · 1.12 KB

Flutter-OpenAPI-Pattern

This Flutter application shows an example of Flutter working with OpenAPIv2 generated code for the petstore example API.

Getting Started

The project should work without any required configuration. Press the floating action button to make requests to the API and observe results in the console.

Building Your Own

To build your own code:

  1. Navigate to the root of your project.
  2. Make sure you have a config file, like flutter.config.json, set up, so you are building code for the flutter environment.
  3. Use openapi-generator-cli (see ‘DownloadJAR’ section) to run the following command. Switch out the path to the jar, input swagger.json and output folder to suit your environment and needs.
java -jar /path/to/openapi-generator-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l dart -c flutter.config.json -o your-api
  1. Update your main project’s pubspec.yaml to include the library
swagger:
    path: ./petstore-api
  1. Access the API using the import:
import 'package:swagger/api.dart';