grafana / grafana-openapi-client-go

Grafana OpenAPI Client for Go
Apache License 2.0
50 stars 7 forks source link

Regenerate client based on more recent API specification #90

Closed dhftah closed 8 months ago

dhftah commented 8 months ago

Currently there is a problem with the object "QueryDataResponse". Specifically, the object has the definition:

 type QueryDataResponse struct {

    // responses
    Responses Responses `json:"Responses,omitempty"`
 }

However, the API return from Grafana is of the form:

 {
    "results": { ... }
 }

Meaning that whenever the response is deserialized into the Responses object, it is empty.

This issue is introduced as the API specification queried by the library¹ contains the bug:

"QueryDataResponse": {
  "description": "It is the return type of a QueryData call.",
  "type": "object",
  "title": "QueryDataResponse contains the results from a QueryDataRequest.",
  "properties": {
    "Responses": {                       ← Not the correct definition
      "$ref": "#/definitions/Responses"
    }
  }
}

This was subsequently fixed, but hasn't yet been updated in the library. This commit updates the library to the most recent commit touching that file, and then regenerates the client.

== Design Notes === Deletion of legacy alerts

There's a large deletion of legacy alerts. I haven't validated all changes to the API against the spec; just consumed it, and regenerated it.

YMMV!

  1. https://raw.githubusercontent.com/grafana/grafana/e916372249833f21ae5c09915a26758a52a87970/public/api-merged.json
CLAassistant commented 8 months ago

CLA assistant check
All committers have signed the CLA.

dhftah commented 8 months ago

the underlying bug is still there; this time Frame is not represented in the Go library nor the definition correctly. I will submit another PR, but can't fix this properly upstream until the api definition is fixed.

I can't submit fixes unfortunately (i am not a "collaborator" to grafana), but will track patches on:

It looks like the dashboard object in its entirety is also missing. The API specification seems to be substantially incomplete?

dhftah commented 7 months ago

thanks @julienduchesne!