Generate OpenAPI contract from backend and regenerate frontend/mobile API clients
Run this skill after modifying backend REST resources or DTOs to sync the OpenAPI contract and regenerate the frontend/mobile clients.
pedalons.api.version in backend/src/main/resources/application.properties is the single source of
truth for the contract version. It feeds both info.version in contracts/openapi.yaml and
GET /api/version (which also reports the git commit the server was built from), so deployments can
be identified. Bump it whenever the contract changes โ semver on the contract itself:
If the generated contracts/openapi.yaml diff turns out to be empty, revert the bump.
The repo root has regenerate.sh, which runs the whole chain end-to-end and fails fast (set -e):
bash regenerate.sh
It performs, in order:
cd backend && mvn clean package -DskipTests โ generates contracts/openapi.{yaml,json}cd frontend && pnpm check โ see belowcd mobile && bash check.sh โ see belowPrefer this over running the steps by hand so nothing drifts out of sync.
cd backend && mvn clean package -DskipTests
Generates contracts/openapi.yaml and contracts/openapi.json.
pnpm checkcd frontend && pnpm check
pnpm check expands to: pnpm install && pnpm generate-api && pnpm generate-routes && pnpm format && pnpm typecheck && pnpm lint && pnpm build.
generate-api runs Orval โ src/api/dto/, src/api/endpoints/, src/api/zod/generate-routes regenerates the UI routes contract (paths.generated.*, AASA, deeplinks) from contracts/routes.yaml โ don't skip this; it's part of the contract surfacetypecheck (tsgo -b) is the real type gate โ not buildcheck.shcd mobile && bash check.sh
check.sh runs: flutter pub get && dart run openapi_retrofit_generator && dart run build_runner build && flutter analyze.
lib/api/generated/clients/ (Retrofit) and lib/api/generated/models/ (Freezed)flutter analyze verifies no Dart errors@Schema(implementation = ...) in @APIResponse annotationsbuild_runner build deletes conflicting outputs by default (the old --delete-conflicting-outputs flag was removed in build_runner 2.5.0)@Tag name collides in the mobile client: the tag becomes a getter on the generated PedalonsApiClient, which already carries static String get version. A tag named Version therefore produces a Dart compile error, and flutter analyze won't catch it (analysis_options.yaml excludes lib/api/generated/**) โ run dart analyze lib/api/generated/ after renaming a tag.@Tag leaves stale generated files: the mobile generator writes the new *_client.dart but doesn't delete the old one; remove it by hand.