Open-Source Wikis

/

Grafana

/

Packages

/

@grafana/api-clients

grafana/grafana

@grafana/api-clients and @grafana/openapi

Two related packages that handle OpenAPI → TypeScript code generation.

@grafana/openapi (packages/grafana-openapi/)

Tooling and templates for generating clients from the merged Grafana OpenAPI spec (public/api-merged.json). The package exposes scripts that:

  1. Read the merged OpenAPI spec.
  2. Run openapi-generator (or a similar tool) with Grafana's customizations.
  3. Emit RTK Query slices into @grafana/api-clients.

Run via:

yarn generate:openapi

@grafana/api-clients (packages/grafana-api-clients/)

The output of the generator. Each Kubernetes-style API group / version produces its own slice. Consumers (public/app, plugins) import the generated hooks like any other RTK Query API:

import { useGetDashboardQuery } from '@grafana/api-clients/dashboard/v0alpha1';

When you change a Go handler's Swagger annotations or a CUE-defined resource:

  1. make swagger-gen regenerates public/api-merged.json.
  2. yarn generate-apis regenerates @grafana/api-clients/src/api/*.gen.ts.
  3. Commit the regenerated files alongside the source change.

See also

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

@grafana/api-clients – Grafana wiki | Factory