open_api_client_generator 1.1.0

SDKdartflutter
Platformandroidioswindowslinuxmacos

OpenApi Client Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec.

OpenApi Client Generator

OpenApi Client Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec.

This library is under development, any help is welcome

The package is written only in dart, other dependencies will not be needed

You can use this package from the command line or by writing a script in dart

Command Line

You can run the generator with the command below

dart run open_api_client_generator \
  --input=http://0.0.0.0:8080/api/v1/swagger/open_api.yaml \
  --output-folder=lib/api \
  --client=dio \
  --data=json_serializable

For all usable parameters use the --help flag

Script

You can also use this package by creating a dart script, here is an example:

import 'package:open_api_client_generator/open_api_client_generator.dart';

void main() async {
  await generateApi(
    options: Options(
      input: Uri.parse('http://0.0.0.0:8080/api/v1/swagger/open_api.yaml'),
      outputFolder: 'lib/api',
    ),
    clientCodec: const DioClientCodec(),
    serializationCodec: const JsonSerializableSerializationCodec(),
  );
}

Arguments

Several http clients, serializers and more are supported.

Client

CommandLineDart ClasspackageDescription
--client=abstractAbstractClientCodecGenerate an abstract client
--client=httpHttpClientCodechttpGenerate a client that uses the http library
--client=dioDioClientCodecdioGenerate a client that uses the dio library

Serialization

CommandLineDart ClasspackageDescription
--serialization=json_serializableJsonSerializableSerializationCodecjson_serializableGenerate serialization use the json_serializable package
--serialization=built_valueBuiltValueSerializationCodecbuilt_valueGenerate serialization use the built_value package

Collection

CommandLineDart ClasspackageDescription
--collection=dartDartCollectionCodecUse List an Map from dart core
--collection=fast_immutable_collectionFastImmutableCollectionCodecfast_immutable_collectionInstead of List and Map use IList and IMap
--collection=built_collectionBuiltCollectionCodecbuilt_collectionInstead of List and Map use BuiltList and BuiltMap

Plugins

CommandLineDart ClasspackageDescription
--plugins=mek_data_classMekDataClassPluginmek_data_classGenerates data classes with Data Class annotation, implements toString and equals

More

shelf_open_api The purpose of this library is to expose the generation of file with open api specifications from your shelf controllers