diff --git a/pkg/registry/apis/datasource/openapi.go b/pkg/registry/apis/datasource/openapi.go index 73b625a250a..e424a7688be 100644 --- a/pkg/registry/apis/datasource/openapi.go +++ b/pkg/registry/apis/datasource/openapi.go @@ -19,6 +19,18 @@ func (b *DataSourceAPIBuilder) PostProcessOpenAPI(oas *spec3.OpenAPI) (*spec3.Op // The plugin description oas.Info.Description = b.pluginJSON.Info.Description + // Add plugin information + info := map[string]any{ + "plugin": b.pluginJSON.ID, + } + if b.pluginJSON.Info.Version != "" { + info["version"] = b.pluginJSON.Info.Version + } + if b.pluginJSON.Info.Build.Time > 0 { + info["build"] = b.pluginJSON.Info.Build.Time + } + oas.Info.VendorExtensible.AddExtension("plugin", info) + // The root api URL root := "/apis/" + b.datasourceResourceInfo.GroupVersion().String() + "/" diff --git a/pkg/tests/apis/openapi_snapshots/testdata.datasource.grafana.app-v0alpha1.json b/pkg/tests/apis/openapi_snapshots/testdata.datasource.grafana.app-v0alpha1.json index 450482baa25..396d72dc0d6 100644 --- a/pkg/tests/apis/openapi_snapshots/testdata.datasource.grafana.app-v0alpha1.json +++ b/pkg/tests/apis/openapi_snapshots/testdata.datasource.grafana.app-v0alpha1.json @@ -2,7 +2,11 @@ "openapi": "3.0.0", "info": { "description": "Generates test data in different forms", - "title": "testdata.datasource.grafana.app/v0alpha1" + "title": "testdata.datasource.grafana.app/v0alpha1", + "plugin": { + "plugin": "grafana-testdata-datasource", + "version": "12.4.0-pre" + } }, "paths": { "/apis/testdata.datasource.grafana.app/v0alpha1/": {