openapi_generator 1.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 63

pub package

This library is the dart/flutter implementation of openapi client sdk code generation.

With this library, you can generate openapi client sdk libraries from your openapi specification right in your flutter/dart projects. (see example)

To be used together with openapi-generator-annotations

Usage #

Include openapi-generator-annotations as a dependency in the dependencies section of your pubspec.yaml file :

dependencies:
  openapi_generator_annotations: ^1.0.2

Add openapi-generator in the dev dependencies section of your pubspec.yaml file:

dev_dependencies:
  openapi_generator: ^1.0.5

Annotate a dart class with @Openapi() annotation

@Openapi(
    additionalProperties:
    AdditionalProperties(pubName: 'petstore_api', pubAuthor: 'Johnny dep'),
    inputSpecFile: 'example/openapi-spec.yaml',
    generatorName: 'dart-jaguar',
    outputDirectory: 'api/petstore_api')
class Example extends OpenapiGeneratorConfig {}

Run command below to generate open api client sdk from spec file specified in annotation.

flutter pub run build_runner build --delete-conflicting-outputs

The api sdk will be generated in the folder specified in the annotation. See examples for more details

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1.0.7 #

  • added support for -t (templateDirectory)
  • minor bug fix

1.0.5 #

  • Updated generator version to 4.3.0

1.0.0 #

  • Updated analyzer to 0.39.4
  • removed validation from input spec

0.1.2 #

  • Updated docs

0.0.1-beta #

  • Initial version.

example/example.dart

import 'package:openapi_generator_annotations/openapi_generator_annotations.dart';

@Openapi(
    additionalProperties:
        AdditionalProperties(pubName: 'petstore_api', pubAuthor: 'Johnny dep'),
    inputSpecFile: 'example/openapi-spec.yaml',
    generatorName: 'dart-jaguar',
    outputDirectory: 'api/petstore_api')
class Example extends OpenapiGeneratorConfig {}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  openapi_generator: ^1.0.7

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:openapi_generator/openapi_generator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
26
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Format lib/src/openapi_generator_runner.dart.

Run dartfmt to format lib/src/openapi_generator_runner.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
analyzer ^0.39.4 0.39.6
build ^1.2.2 1.2.2
cli_util ^0.1.3+2 0.1.3+2
openapi_generator_annotations ^1.0.7 1.0.7
openapi_generator_cli ^1.0.5 1.0.5
path ^1.6.4 1.6.4
source_gen ^0.9.0 0.9.5
Transitive dependencies
_fe_analyzer_shared 2.1.0
args 1.6.0
async 2.4.1
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
dart_style 1.3.4
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
logging 0.11.4
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.9.3
pub_semver 1.4.4
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+14
yaml 2.2.0
Dev dependencies
build_config ^0.4.2
build_runner ^1.7.4
pedantic ^1.8.0 1.9.0
test ^1.6.0