Last updated:
0 purchases
openapi schema generator
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
copied to clipboard
Usage #
> dart pub global run openapi_schema_generator:generate -o ./package/ ./definitions/pets.json
copied to clipboard
For generating models :
cd package
flutter pub get
flutter pub run build_runner build
copied to clipboard
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.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.