* API: Fix swagger specification
* Validate specification after generation
(cherry picked from commit 6112bd0c63)
Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
This commit is contained in:
co-authored by
Sofia Papagiannaki
parent
77dccd54ca
commit
63c1a2706f
@@ -50,7 +50,7 @@ $(SPEC_TARGET): $(API_DEFINITION_FILES) ## Generate API spec
|
||||
-x "github.com/prometheus/alertmanager" \
|
||||
-i /grafana/pkg/api/docs/tags.json
|
||||
|
||||
swagger-api-spec: gen-go $(SPEC_TARGET) $(MERGED_SPEC_TARGET)
|
||||
swagger-api-spec: gen-go $(SPEC_TARGET) $(MERGED_SPEC_TARGET) validate-api-spec
|
||||
|
||||
$(NGALERT_SPEC_TARGET):
|
||||
+$(MAKE) -C pkg/services/ngalert/api/tooling api.json
|
||||
@@ -67,7 +67,7 @@ ensure_go-swagger_mac:
|
||||
-x "github.com/prometheus/alertmanager" \
|
||||
-i pkg/api/docs/tags.json
|
||||
|
||||
swagger-api-spec-mac: gen-go --swagger-api-spec-mac $(MERGED_SPEC_TARGET)
|
||||
swagger-api-spec-mac: gen-go --swagger-api-spec-mac $(MERGED_SPEC_TARGET) validate-api-spec
|
||||
|
||||
validate-api-spec: $(MERGED_SPEC_TARGET) ## Validate API spec
|
||||
docker run --rm -it \
|
||||
|
||||
@@ -113,7 +113,7 @@ import (
|
||||
// 401: unauthorisedError
|
||||
// 500: internalServerError
|
||||
|
||||
// swagger:parameters updateAnnotation patchAnnotation deleteAnnotation
|
||||
// swagger:parameters getAnnotation updateAnnotation patchAnnotation deleteAnnotation
|
||||
type AnnotationIDParam struct {
|
||||
// in:path
|
||||
// required:true
|
||||
|
||||
@@ -334,7 +334,6 @@ import (
|
||||
// 500: internalServerError
|
||||
|
||||
// swagger:parameters updateDatasourceByID deleteDatasourceByID getDatasourceByID datasourceProxyGETcalls datasourceProxyPOSTcalls datasourceProxyDELETEcalls
|
||||
// swagger:parameters enablePermissions disablePermissions getPermissions deletePermissions
|
||||
// swagger:parameters checkDatasourceHealthByID fetchDatasourceResourcesByID
|
||||
type DatasourceID struct {
|
||||
// in:path
|
||||
|
||||
+20
-11
@@ -2258,6 +2258,15 @@
|
||||
"tags": ["annotations"],
|
||||
"summary": "Get Annotation by Id.",
|
||||
"operationId": "getAnnotation",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "AnnotationID",
|
||||
"name": "annotation_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/getAnnotationResponse"
|
||||
@@ -3809,7 +3818,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/datasources/{datasource_id}/disable-permissions": {
|
||||
"/datasources/{datasourceId}/disable-permissions": {
|
||||
"post": {
|
||||
"description": "Disables permissions for the data source with the given id. All existing permissions will be removed and anyone will be able to query the data source.\n\nYou need to have a permission with action `datasources.permissions:toggle` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).",
|
||||
"tags": ["datasource_permissions", "enterprise"],
|
||||
@@ -3819,7 +3828,7 @@
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "id",
|
||||
"name": "datasourceId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
@@ -3846,7 +3855,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/datasources/{datasource_id}/enable-permissions": {
|
||||
"/datasources/{datasourceId}/enable-permissions": {
|
||||
"post": {
|
||||
"description": "Enables permissions for the data source with the given id.\nNo one except Org Admins will be able to query the data source until permissions have been added\nwhich permit certain users or teams to query the data source.\n\nYou need to have a permission with action `datasources.permissions:toggle` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).",
|
||||
"tags": ["datasource_permissions", "enterprise"],
|
||||
@@ -3856,7 +3865,7 @@
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "id",
|
||||
"name": "datasourceId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
@@ -3883,7 +3892,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/datasources/{datasource_id}/permissions": {
|
||||
"/datasources/{datasourceId}/permissions": {
|
||||
"get": {
|
||||
"description": "Gets all existing permissions for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:read` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).",
|
||||
"tags": ["datasource_permissions", "enterprise"],
|
||||
@@ -3893,7 +3902,7 @@
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "id",
|
||||
"name": "datasourceId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
@@ -3917,7 +3926,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/datasources/{datasource_id}/permissions/{permissionId}": {
|
||||
"/datasources/{datasourceId}/permissions/{permissionId}": {
|
||||
"delete": {
|
||||
"description": "Removes the permission with the given permissionId for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:delete` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).",
|
||||
"tags": ["datasource_permissions", "enterprise"],
|
||||
@@ -3926,15 +3935,15 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "PermissionID",
|
||||
"name": "permissionId",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "datasourceId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "id",
|
||||
"x-go-name": "PermissionID",
|
||||
"name": "permissionId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
|
||||
+20
-11
@@ -2258,6 +2258,15 @@
|
||||
"tags": ["annotations"],
|
||||
"summary": "Get Annotation by Id.",
|
||||
"operationId": "getAnnotation",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "AnnotationID",
|
||||
"name": "annotation_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/getAnnotationResponse"
|
||||
@@ -3809,7 +3818,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/datasources/{datasource_id}/disable-permissions": {
|
||||
"/datasources/{datasourceId}/disable-permissions": {
|
||||
"post": {
|
||||
"description": "Disables permissions for the data source with the given id. All existing permissions will be removed and anyone will be able to query the data source.\n\nYou need to have a permission with action `datasources.permissions:toggle` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).",
|
||||
"tags": ["datasource_permissions", "enterprise"],
|
||||
@@ -3819,7 +3828,7 @@
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "id",
|
||||
"name": "datasourceId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
@@ -3846,7 +3855,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/datasources/{datasource_id}/enable-permissions": {
|
||||
"/datasources/{datasourceId}/enable-permissions": {
|
||||
"post": {
|
||||
"description": "Enables permissions for the data source with the given id.\nNo one except Org Admins will be able to query the data source until permissions have been added\nwhich permit certain users or teams to query the data source.\n\nYou need to have a permission with action `datasources.permissions:toggle` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).",
|
||||
"tags": ["datasource_permissions", "enterprise"],
|
||||
@@ -3856,7 +3865,7 @@
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "id",
|
||||
"name": "datasourceId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
@@ -3883,7 +3892,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/datasources/{datasource_id}/permissions": {
|
||||
"/datasources/{datasourceId}/permissions": {
|
||||
"get": {
|
||||
"description": "Gets all existing permissions for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:read` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).",
|
||||
"tags": ["datasource_permissions", "enterprise"],
|
||||
@@ -3893,7 +3902,7 @@
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "id",
|
||||
"name": "datasourceId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
@@ -3917,7 +3926,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/datasources/{datasource_id}/permissions/{permissionId}": {
|
||||
"/datasources/{datasourceId}/permissions/{permissionId}": {
|
||||
"delete": {
|
||||
"description": "Removes the permission with the given permissionId for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:delete` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).",
|
||||
"tags": ["datasource_permissions", "enterprise"],
|
||||
@@ -3926,15 +3935,15 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "PermissionID",
|
||||
"name": "permissionId",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "datasourceId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "DatasourceID",
|
||||
"name": "id",
|
||||
"x-go-name": "PermissionID",
|
||||
"name": "permissionId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user