packages/grafana-api-clients/src/generator/README.md
This generator automates the process of creating RTK Query API clients for Grafana's API groups. It replaces the manual steps outlined in the main API documentation.
yarn generate:api-client
The CLI will prompt for:
dashboard)<group-name>.grafana.app)v0alpha1)<group-name>API<version>). This will also be used as the API's named export.createDashboard,updateDashboard). If not provided, all endpoints will be included.If the selected API group/version already has a complete scaffold, the CLI will prompt to update the existing client instead. Update mode regenerates endpoints from the existing config and does not modify config entries, Redux middleware/reducers/imports, package exports, or scaffold files. If only part of the scaffold exists, the CLI preserves existing files, fills in missing config/wiring/export entries, and regenerates endpoints.
For the full end-to-end update flow from API types to OpenAPI snapshots to RTK Query endpoints, see Updating generated clients.
The generator automates the following:
baseAPI.ts file for the API groupscripts/generate-rtk-apis.ts for OSS APIslocal/generate-enterprise-apis.ts for Enterprise APIsindex.ts file with proper exportsrtkq/index.tspackage.json exports to include the new API clientFor complete existing clients, the generator skips the create steps and only runs the appropriate endpoint generation command. For partial clients, it fills in the missing create steps first.
openapi_snapshots directoryIf an error about a missing OpenAPI schema appears, check that:
TestIntegrationOpenAPIs test has been run to generate the schema (step 1 in the main API documentation).packages/grafana-openapi/src/apis/<group>-<version>.json.grafana.appv0alpha1, v1beta2, etc.API