-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenAPI: Paths to rules provisioning are incorrect in api-merged.json #76578
Comments
Note: this is apparently a duplicate of #76386 but this one has a lot more detail on reproducing the issue. |
I opened up this ticket a few days ago, I wanted to call it out as this seems very much related. #76386 |
Thank you both @safaci2000 @mbarrien for finding this! I can confirm that 17 endpoints in the OAPI spec have a path with This is an issue because we initialise the OAPI generated client to point at We need to update the swagger annotation for these 17 paths to not prepend |
Thank you for the detailed report, we will investigate what can be done to fix this. Previous trials merging our APIs have not been successful due to various issues. |
Would be fixed by #79025 |
What happened?
In the public api-merged.json file the path to all the rules provisioning APIs are incorrect.
grafana/public/api-merged.json
Lines 2468 to 3372 in 889576a
(the commit pointed to is the current HEAD of main) shows several paths that start with "/api/v1/provisioning".
However the openapi file already has the following basePath:
grafana/public/api-merged.json
Line 23 in 889576a
So it already prepends
/api
to all paths. In combination this ends up with a paths like/api/api/v1/provisioning/alert-rules
in the generated code (note the double/api
), which 404s. All other paths in the file are missing the "/api" prefix.This is evident when using Golang generated apis from this OpenAPI file. The self-contained example I've included below uses go-swagger v0.30.5, the same library used in https://github.com/grafana/grafana-openapi-client-go (as tracked in #47287)
What did you expect to happen?
We are correctly able to access the resources in the API.
Did this work before?
Not sure. Haven't tried to use OpenAPI with earlier versions of Grafana.
How do we reproduce it?
This is a minimized, self-contained reproduction that originally comes from code inspired from https://github.com/esnet/grafana-swagger-api-golang
`
Save the following to
main.go
:will result in the following error message:
Notice in the first line the
GET /api/api/v1...
The code work as expected if you run the following
Is the bug inside a dashboard panel?
No response
Environment (with versions)?
No response
Grafana platform?
I use Grafana Cloud
Datasource(s)?
No response
The text was updated successfully, but these errors were encountered: