OpenAPI generator for Dart & Flutter

Related tags

Utilities fantom
Overview

Fantom

Fantom is a cli tool for generating API layer based on OpenAPI Spec.

Usage

  1. Install fantom
    $ dart pub global activate fantom
  2. Generate API client
    $ fantom generate openapi.yaml --dir=lib/src/network 
    Note: it will generates models in lib/src/network/model directory and APIs in lib/src/network/api directory

More Advanced Options

  • Separate models and APIs directories

    $ fantom generate openapi.yaml --model-dir=lib/src/model --api-dir=lib/src/network
  • Generate API layer as a standalone dart package

    $ fantom generate openapi.yaml --package=packages/network

    Note: it will generates a package called network inside packages/network from where fantom generate command runs.

  • Define configs inside pubspec.yaml

    $ fantom generate 
    # or
    $ fantom generate pubspec.yaml

    Your pubspec.yaml file:

    fantom:
      - openapi: openapi.yaml   
      - api-dir: lib/src/network
      - model-dir: lib/src/model
    # or
    fantom: 
      - openapi: openapi.yaml
      - dir: lib/src/network
    # or
    fantom: 
      - openapi: openapi.yaml
      - package: packages/network  

Activate from Source

Activate fantom from source code:

$ export PATH="$PATH":"$HOME/.pub-cache/bin"

$ dart pub global activate --source path path_to/fantom

To deactive:

$ dart pub global deactivate fantom
You might also like...

A Flutter curl-command generator for Dio

A Flutter curl-command generator for Dio

curl_logger_dio_interceptor A Flutter curl-command generator for Dio. Easily test your Flutter-made requests in your favorite terminal or even in Post

Nov 17, 2022

Flutter Word generator

wordpair_generator A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Dec 3, 2021

Random color generator for Flutter

Random color generator for Flutter

Random color generator Pub link: https://pub.dartlang.org/packages/random_color This library will generate random colors that are visually pleasing an

Jun 13, 2022

A Flutter Word generator App to improve English vocabulary

A Flutter Word generator App to improve English vocabulary

Word generator App to improve English vocabulary: Add English words you don't know and their translation, then you need to answer what is the translat

Dec 12, 2021

A certificate generator app developed in Flutter with love.

A certificate generator app developed in Flutter with love.

Holden Certificate Generator made with Flutter. Dependencies spreadsheet_decoder path_provider file_picker pdf_viewer_plugin pdf permission_handler sh

Jan 4, 2023

Flutter Google Sheet localizations generator

 Flutter Google Sheet localizations generator

Flutter Google Sheet localizations generator Generates a localizations delegate from an online Google Sheet file. Install Add the following to your pu

Dec 19, 2022

GPT-3 recipe generator for the GPT-3 Makeathon by TUM.AI. Developed by team Taste the data.

GPT-3 recipe generator for the GPT-3 Makeathon by TUM.AI. Developed by team Taste the data.

GPT-3 Makeathon by TUM.AI - Team: Taste the Data Team - Taste the Data: Carmen Heger @stedomedo David Stiftl @stiftlD Christopher Schütz @cdschtz

Dec 4, 2022

A generator to create config class from json files that support many environments

A generator to create config class from json files that support many environments. Motivation If you use a json file to config your applications, perp

Oct 9, 2021
Comments
  • Null check operator used on a null value

    Null check operator used on a null value

    Null check operator used on a null value #0 ResponseClassGenerator.generateResponse.<anonymous closure> (package:fantom/src/generator/response/response_class_generator.dart:41:45) #1 MapMixin.map (dart:collection/maps.dart:170:28) #2 ResponseClassGenerator.generateResponse (package:fantom/src/generator/response/response_class_generator.dart:38:68) #3 ResponseClassGenerator.generateResponses.<anonymous closure> (package:fantom/src/generator/response/response_class_generator.dart:89:29) #4 MapMixin.map (dart:collection/maps.dart:170:28) #5 ResponseClassGenerator.generateResponses (package:fantom/src/generator/response/response_class_generator.dart:81:71) #6 MethodResponseParser.parseResponses (package:fantom/src/generator/api/method/response_parser.dart:15:55) #7 ApiMethodGenerator._generateOperation (package:fantom/src/generator/api/method/api_method_generator.dart:117:63) #8 ApiMethodGenerator.generateMethods (package:fantom/src/generator/api/method/api_method_generator.dart:79:11) #9 ApiSubClassGenerator._generateApiMethods (package:fantom/src/generator/api/sub_class/api_sub_class_generator.dart:66:26) #10 ApiSubClassGenerator._generateFileContent (package:fantom/src/generator/api/sub_class/api_sub_class_generator.dart:35:17) #11 ApiSubClassGenerator.generate (package:fantom/src/generator/api/sub_class/api_sub_class_generator.dart:18:25) #12 ApiClassGenerator._generateApiClasses (package:fantom/src/generator/api/class/api_class_generator.dart:33:45) #13 ApiClassGenerator.generate (package:fantom/src/generator/api/class/api_class_generator.dart:20:24) #14 Generator.generate (package:fantom/src/generator/generator.dart:67:45) #15 GenerateCommand.runCommand (package:fantom/src/cli/commands/generate.dart:165:10) #16 BaseCommand.run (package:fantom/src/cli/commands/base_command.dart:38:12) <asynchronous suspension> #17 CommandRunner.runCommand (package:args/command_runner.dart:209:13) <asynchronous suspension> #18 FantomCli.run (package:fantom/src/cli/fantom_cli.dart:38:22) <asynchronous suspension> #19 main (file:///Users/samrd/Dev/Dart/Projects/fantom/bin/main.dart:6:18) <asynchronous suspension>

    opened by rasouliali1379 2
  • ToDo

    ToDo

    HIGH PRIORITY:

    • [x] add header parser to parse and generate header parameters for api methods (payam)
    • [x] complete generation of ApiClass (payam)
    • [x] add support for methods that require multipart request bodies. (beware of issue with MultiPart.fromFile() not working in the web) (alireza)
    • [x] get the version 3 openapi specs of a big backend framework and test fantom on that
    • [x] enum generation (amirreza)
    • [x] add exception handling for responses (payam)
    • [x] add either type extension function for responses (payam)
    • [x] add feature to exclude paths and parameters (alireza)
    • [x] migrate enum and schema generation to optional-less model (amirreza)

    Can be done later (but still important)

    • [x] add custom body to to generated types for RequestBodies (alireza)
    • [x] use compute or similar approach to deserialize large response bodies
    • [x] add exception handling (needs discussion)
    • [x] remove using dart_sealed in the benefit of having simpler generated types. (this'll take time)
    • [x] make file-writer to read necessary files from source code instead of manually copying them

    Feature Ideas that we can add in the future

    • [ ] add a decent dio Interceptor that converts dio requests to curl
    • [ ] add database support
    • [ ] mixed object code generation
    • [ ] make toJson and fromJson generation more flat and simpler
    opened by easazade 0
Owner
6thSolution
6thSolution
Swagger/OpenAPI code generator based on Chopper and JsonAnnotation for Flutter

Code partially generated with chopper ?? Build dart types from Swagger/OpenAPI schemas SwaggerDartCodeGenerator is a code generator that looks for *.s

null 187 Jan 5, 2023
Environment specific config generator for Dart and Flutter applications during CI/CD builds

Environment Config Generator Environment specific config generator. Allows to specify env configuration during CI/CD build. Primarily created to simpl

Denis Beketsky 86 Dec 2, 2022
🚀The Flutter dart code generator from zeplin. ex) Container, Text, Color, TextStyle, ... - Save your time.

Flutter Gen Zeplin Extension ?? The Flutter dart code generator from zeplin. ex) Container, Text, Color, TextStyle, ... - Save your time. ⬇ 1.1k Getti

NAVER 49 Oct 12, 2022
Destiny is a new, mock-data generator for Dart/Flutter

Destiny is a new, mock-data generator for Dart/Flutter. It uses static methods couched in a destiny namespace as the API.

Aditya Kishore 11 Sep 16, 2022
Dart Code Generator for generating mapper classes

Smartstruct - Dart bean mappings - the easy nullsafe way! Code generator for generating type-safe mappers in dart, inspired by https://mapstruct.org/

Nils 28 Nov 29, 2022
The Dart code generator for your package versions. 🎯

The Dart code generator for your package versions. There is no way to get the package version from the code in the Dart ecosystem. Installation Add bu

Daichi Furiya 12 Dec 14, 2022
Dart R-file generator for build_runner

r_resources This package is made for R-file code generation using build_runner.

Ivanov Nikita 0 Dec 17, 2021
Arissounddart - a Command-line SoundSprite generator for Dart

SoundDart SoundDart is a Command-line SoundSprite generator for Dart. It require

Behruz Hurramov 1 Jan 9, 2022
Starter project and code generator for Flutter/Redux

Flutter Redux Starter/Code Generator Videos Short video ~ 1 minute Long video ~ 10 minutes We're using this approach to develop the Flutter app for In

Hillel Coren 278 Dec 12, 2022
The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs.

The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs. Inspired by SwiftGen. Motivation Using asset path str

FlutterGen 1.1k Jan 6, 2023