Simple, hackable Open API generator for Dart
This is not designed to be a full implementation of OpenAPI. Currently just enough to generate beautiful Dart bindings for spacetraders.io.
Patches welcome to expand it to support a wider set of OpenAPI.
NOTE: This readme as written is aspirational. The code is not yet all working.
dart run space_gen
- Generates good quality, modern Dart code
- Not a complete implementation of OpenAPI
- Generates layered output, which can be used in pieces (TBD)
- Generates testable (and tested) code (TBD)
- Phases
- Parse OpenAPI
- Resolve references
- Render Dart code
- OpenAPI does one-class-per-file, remove "models".
- OpenAPI uniques inline schema based on property layout ignoring names.
- Add support for required keys.
- Actually make the networking work.
- Implement operator== and hashCode?
- Avoid keyword collisions in property names (e.g. yield).
- Generate tests. #1
- Dart 3.0+ only (sound null safety)
- Model code round trips through JSON correctly (TBD)
As of August 2023, there are two separate (soon to be combined?) OpenAPI generators for Dart. One for package:http and one for package:dio. I only ever used the http one and it had lots of bugs. I looked at fixing them in OpenAPI, but failed to figure out how to hack on the OpenAPI generator (Java) or successfully interact with the community (several separate slacks).