API: Extract OpenAPI specification from source code using go-swagger (#40528) (#45061)

* API: Using go-swagger for extracting OpenAPI specification from source code

* Merge Grafana Alerting spec

* Include enterprise endpoints (if enabled)

* Serve SwaggerUI under feature flag

* Fix building dev docker images

* Configure swaggerUI

* Add missing json tags

Co-authored-by: Ying WANG <ying.wang@grafana.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
(cherry picked from commit 35fe58de37)
This commit is contained in:
Grot (@grafanabot)
2022-02-08 13:52:05 +01:00
committed by GitHub
parent c6a58003d1
commit 08ad99c36e
61 changed files with 35314 additions and 74 deletions
+4 -4
View File
@@ -55,7 +55,7 @@ type CreateAlertNotificationCommand struct {
OrgId int64 `json:"-"`
EncryptedSecureSettings map[string][]byte `json:"-"`
Result *AlertNotification
Result *AlertNotification `json:"-"`
}
type UpdateAlertNotificationCommand struct {
@@ -73,7 +73,7 @@ type UpdateAlertNotificationCommand struct {
OrgId int64 `json:"-"`
EncryptedSecureSettings map[string][]byte `json:"-"`
Result *AlertNotification
Result *AlertNotification `json:"-"`
}
type UpdateAlertNotificationWithUidCommand struct {
@@ -88,8 +88,8 @@ type UpdateAlertNotificationWithUidCommand struct {
Settings *simplejson.Json `json:"settings" binding:"Required"`
SecureSettings map[string]string `json:"secureSettings"`
OrgId int64
Result *AlertNotification
OrgId int64 `json:"-"`
Result *AlertNotification `json:"-"`
}
type DeleteAlertNotificationCommand struct {
+18 -3
View File
@@ -44,17 +44,32 @@ type DashboardSnapshotDTO struct {
// -----------------
// COMMANDS
// swagger:model
type CreateDashboardSnapshotCommand struct {
// The complete dashboard model.
// required:true
Dashboard *simplejson.Json `json:"dashboard" binding:"Required"`
Name string `json:"name"`
Expires int64 `json:"expires"`
// Snapshot name
// required:false
Name string `json:"name"`
// When the snapshot should expire in seconds in seconds. Default is never to expire.
// required:false
// default:0
Expires int64 `json:"expires"`
// these are passed when storing an external snapshot ref
// Save the snapshot on an external server rather than locally.
// required:false
// default: false
External bool `json:"external"`
ExternalUrl string `json:"-"`
ExternalDeleteUrl string `json:"-"`
Key string `json:"key"`
// Define the unique key. Required if `external` is `true`.
// required:false
Key string `json:"key"`
// Unique key used to delete the snapshot. It is different from the `key` so that only the creator can delete the snapshot. Required if `external` is `true`.
// required:false
DeleteKey string `json:"deleteKey"`
OrgId int64 `json:"-"`
+2 -2
View File
@@ -349,13 +349,13 @@ type SaveDashboardCommand struct {
UpdatedAt time.Time
Result *Dashboard
Result *Dashboard `json:"-"`
}
type TrimDashboardCommand struct {
Dashboard *simplejson.Json `json:"dashboard" binding:"Required"`
Meta *simplejson.Json `json:"meta"`
Result *Dashboard
Result *Dashboard `json:"-"`
}
type DashboardProvisioning struct {
+8 -2
View File
@@ -92,7 +92,7 @@ type AddDataSourceCommand struct {
ReadOnly bool `json:"-"`
EncryptedSecureJsonData map[string][]byte `json:"-"`
Result *DataSource
Result *DataSource `json:"-"`
}
// Also acts as api DTO
@@ -119,7 +119,7 @@ type UpdateDataSourceCommand struct {
ReadOnly bool `json:"-"`
EncryptedSecureJsonData map[string][]byte `json:"-"`
Result *DataSource
Result *DataSource `json:"-"`
}
// DeleteDataSourceCommand will delete a DataSource based on OrgID as well as the UID (preferred), ID, or Name.
@@ -171,6 +171,12 @@ type GetDataSourceQuery struct {
// Permissions
// ---------------------
// Datasource permission
// Description:
// * `0` - No Access
// * `1` - Query
// Enum: 0,1
// swagger:model
type DsPermissionType int
const (
+2 -2
View File
@@ -62,7 +62,7 @@ type CreateFolderCommand struct {
Uid string `json:"uid"`
Title string `json:"title"`
Result *Folder
Result *Folder `json:"-"`
}
type UpdateFolderCommand struct {
@@ -71,7 +71,7 @@ type UpdateFolderCommand struct {
Version int `json:"version"`
Overwrite bool `json:"overwrite"`
Result *Folder
Result *Folder `json:"-"`
}
//