openapi_schema_generator 0.5.35 copy "openapi_schema_generator: ^0.5.35" to clipboard
openapi_schema_generator: ^0.5.35 copied to clipboard

An opiniated generator for OpenAPI definitions.

openapi_schema_generator #

An opiniated generator for OpenAPI definitions.

It only works for a subset of definitions and aims to make generated code more human readable by using freezed package for modeling data.

Install #

> dart pub global activate openapi_schema_generator

Usage #

> dart pub global run openapi_schema_generator:generate -o ./package/ ./definitions/pets.json

For generating models :

cd package
flutter pub get
flutter pub run build_runner build

Definition rules #

  • All schemas must be defined in components.schema and referenced from child objects and routes.
  • Route parameters must be of basic types (string, integer, number).

FAQ #

Why don`t you simply use the official OpenAPI generator ?

The OpenAPI official generator supports dart language, but the generated code seems over complicated in my opinion. It also generates mutable objects which makes object instantiation less simple that a simply constructor/copyWith combination.

And the other reason is that oneOf isn't supported yet for Dart.

What do you mean by "opiniated"?

The supported definition subset is only designed to support my own needs. So there are specific rules that may not fit the way you write your OpenAPI definitions, but this limitations allow me to simplify the maintenance since I work on it alone, on my spare time.

Where can I find an example supported definition and generated code ?

You have one in the repository.

0
likes
100
pub points
0%
popularity

Publisher

unverified uploader

An opiniated generator for OpenAPI definitions.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

args, code_builder, collection, dart_style, logging, open_api_forked, path, recase

More

Packages that depend on openapi_schema_generator