Files
grafana/pkg/tests/apis/openapi_snapshots
Ivan Ortega Alba e463781077 Schema: convert dashboards from v1beta1 to v2beta1 (#109037)
- Implement full conversion pipeline from v1beta1 → v2beta1
- Ensure frontend–backend parity for all dashboard serialization paths
- Add automatic data loss detection for conversions (panels, queries, annotations, links, variables)
- Extract atomic conversion functions for v0 → v1beta1 → v2alpha1 → v2beta1
- Introduce conversion metrics and detailed logging for loss tracking
- Normalize datasource resolution, defaults, and annotation processing
- Improve panel layout serialization and y-coordinate normalization
- Fix inconsistencies in nested panels and collapsed row behavior
- Refine variable handling:
  - Filter refId from variable query specs
  - Default variable refresh to 'never' (matches frontend)
  - Fix constant and interval variable handling for missing queries
- Unify schema defaults (enable, hide, iconColor, editable, liveNow)
- Fix pluginId usage (UID vs type) and datasource references
- Fix metrics.go bug swallowing errors (return nil → return err)
- Add tests for version-specific conversion error handling
- Add data loss detection tests using source/target version comparison
- Clean up lint issues, legacy code, and redundant files
- Update OpenAPI snapshots and migrated dashboards
- Improve backend migrator to reuse datasource provider and match frontend logic

Co-authored-by: Haris Rozajac <haris.rozajac12@gmail.com>
Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
2025-11-12 11:43:46 +01:00
..

This folder contains a rendered OpenAPI file for each group/version. The “real” OpenAPI is generated by the running server, but the files here are used to build static frontend clients.

Generating RTK API Clients

The RTK API clients are generated from processed OpenAPI files using the scripts/process-specs.ts script. The source files are in pkg/tests/apis/openapi_snapshots, and the processed files are stored in the data/openapi directory. Spec processing happens as part of yarn generate-apis task, but can also be triggered separately (see below).

To generate or update the RTK API clients:

  1. If generating or updating an RTK client for the first time, update scripts/generate-rtk-apis.js so schemaFile points to the processed spec files, for example:

    '../public/app/features/dashboards/api/endpoints.gen.ts': {
      schemaFile: '../data/openapi/dashboard.grafana.app-v0alpha1.json',
    },
    
  2. Generate or update the OpenAPI spec files by running:

    go test pkg/tests/apis/openapi_test.go
    

    If generating an RTK client for a new API, also add a new group/version of the API to the groups slice. If the API is behind a feature toggle, add the toggle to EnableFeatureToggles in pkg/tests/apis/openapi_test.go.

  3. Run:

    yarn generate-apis
    

    This command generates (or updates) the spec files in the data/openapi directory and generates the RTK API clients.

If you want to process the OpenAPI files without generating the RTK API clients (for example, if you have a separate generate-rtk-apis file), run:

yarn process-specs