API client
Regenerate the Dart API client in lib/api/ when the backend API changes. Don't edit it by hand. openapi-generator generates it with the dart-dio generator from the OpenAPI 3.0 document of SchulyServer. The app uses it as the local package schuly_api, through a path: reference in pubspec.yaml.
Regenerate the client
Start the backend on http://localhost:5033, then run:
sh
bun run apigen # regenerate from http://localhost:5033/openapi/v1.json
bun run apigen:local # same target, explicit local aliasapigen runs three steps:
- Generate: runs
openapi-generator-cli generate -g dart-dioagainst the live document and writes tolib/api, withpubName=schuly_apiandpubLibrary=schuly_api. - Patch (
apigen:patch): changes the SDK constraint inlib/api/pubspec.yaml. The generator resets it to'>=2.18.0 <4.0.0', which breaks the build with a part-file language-version mismatch. The patch sets^3.10.0. It's abun -eone-liner, so it works in any shell. - Build (
apigen:build): runsdart pub getanddart run build_runner build --delete-conflicting-outputsinlib/apito produce the.g.dartserialization code.
Good to know
openapi.jsonis gitignored. Regenerate from the running backend instead of committing a copy.analysis_options.yamlexcludeslib/api/**fromflutter analyze, so generated code never triggers lint errors.- If the
.g.dartfiles go stale, runbun run apigenor onlybun run apigen:build.
