Swagger: Rename Spec to Preferences (#78226)

The definition for preferences is globally named `Spec` because that's the type that cue outputs
This adds a swagger annotation to rename the definition in the swagger schema to `Preferences`
This will be easier to use in generated clients
This commit is contained in:
Julien Duchesne 2023-12-04 09:51:09 -05:00 committed by GitHub
parent 2fb207ba13
commit 637cfa89be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 117 additions and 101 deletions

View File

@ -21,7 +21,7 @@ The user or team frontend preferences
| Property | Type | Required | Default | Description |
|------------|---------------------|----------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `metadata` | [object](#metadata) | **Yes** | | metadata contains embedded CommonMetadata and can be extended with custom string fields<br/>TODO: use CommonMetadata instead of redefining here; currently needs to be defined here<br/>without external reference as using the CommonMetadata reference breaks thema codegen. |
| `spec` | [object](#spec) | **Yes** | | |
| `spec` | [object](#spec) | **Yes** | | Spec defines user, team or org Grafana preferences<br/>swagger:model Preferences |
| `status` | [object](#status) | **Yes** | | |
### Metadata
@ -69,6 +69,9 @@ extraFields is reserved for any fields that are pulled from the API server metad
### Spec
Spec defines user, team or org Grafana preferences
swagger:model Preferences
| Property | Type | Required | Default | Description |
|---------------------|---------------------------------------------------|----------|---------|---------------------------------------------------------------------------------|
| `cookiePreferences` | [CookiePreferences](#cookiepreferences) | No | | |

View File

@ -8,6 +8,8 @@ description: "The user or team frontend preferences"
lineage: schemas: [{
version: [0, 0]
schema: {
// Spec defines user, team or org Grafana preferences
// swagger:model Preferences
spec: {
// UID for the home dashboard
homeDashboardUID?: string

View File

@ -21,6 +21,10 @@ export interface CookiePreferences {
performance?: Record<string, unknown>;
}
/**
* Spec defines user, team or org Grafana preferences
* swagger:model Preferences
*/
export interface Preferences {
/**
* Cookie preferences

View File

@ -22,7 +22,8 @@ type QueryHistoryPreference struct {
HomeTab *string `json:"homeTab,omitempty"`
}
// Spec defines model for Spec.
// Spec defines user, team or org Grafana preferences
// swagger:model Preferences
type Spec struct {
CookiePreferences *CookiePreferences `json:"cookiePreferences,omitempty"`

View File

@ -5592,6 +5592,38 @@
}
}
},
"Preferences": {
"description": "Spec defines user, team or org Grafana preferences",
"type": "object",
"properties": {
"cookiePreferences": {
"$ref": "#/definitions/CookiePreferences"
},
"homeDashboardUID": {
"description": "UID for the home dashboard",
"type": "string"
},
"language": {
"description": "Selected language (beta)",
"type": "string"
},
"queryHistory": {
"$ref": "#/definitions/QueryHistoryPreference"
},
"theme": {
"description": "Theme light, dark, empty is default",
"type": "string"
},
"timezone": {
"description": "The timezone selection\nTODO: this should use the timezone defined in common",
"type": "string"
},
"weekStart": {
"description": "WeekStart day of the week (sunday, monday, etc)",
"type": "string"
}
}
},
"PrometheusRemoteWriteTargetJSON": {
"type": "object",
"properties": {
@ -5777,8 +5809,10 @@
},
"QueryHistoryPreference": {
"type": "object",
"title": "QueryHistoryPreference defines model for QueryHistoryPreference.",
"properties": {
"homeTab": {
"description": "HomeTab one of: '' | 'query' | 'starred';",
"type": "string"
}
}
@ -6670,38 +6704,6 @@
"type": "integer",
"format": "int64"
},
"Spec": {
"type": "object",
"title": "Spec defines model for Spec.",
"properties": {
"cookiePreferences": {
"$ref": "#/definitions/CookiePreferences"
},
"homeDashboardUID": {
"description": "UID for the home dashboard",
"type": "string"
},
"language": {
"description": "Selected language (beta)",
"type": "string"
},
"queryHistory": {
"$ref": "#/definitions/QueryHistoryPreference"
},
"theme": {
"description": "Theme light, dark, empty is default",
"type": "string"
},
"timezone": {
"description": "The timezone selection\nTODO: this should use the timezone defined in common",
"type": "string"
},
"weekStart": {
"description": "WeekStart day of the week (sunday, monday, etc)",
"type": "string"
}
}
},
"State": {
"type": "string"
},
@ -8574,7 +8576,7 @@
"getPreferencesResponse": {
"description": "",
"schema": {
"$ref": "#/definitions/Spec"
"$ref": "#/definitions/Preferences"
}
},
"getPublicAnnotationsResponse": {

View File

@ -16832,6 +16832,38 @@
}
}
},
"Preferences": {
"description": "Spec defines user, team or org Grafana preferences",
"type": "object",
"properties": {
"cookiePreferences": {
"$ref": "#/definitions/CookiePreferences"
},
"homeDashboardUID": {
"description": "UID for the home dashboard",
"type": "string"
},
"language": {
"description": "Selected language (beta)",
"type": "string"
},
"queryHistory": {
"$ref": "#/definitions/QueryHistoryPreference"
},
"theme": {
"description": "Theme light, dark, empty is default",
"type": "string"
},
"timezone": {
"description": "The timezone selection\nTODO: this should use the timezone defined in common",
"type": "string"
},
"weekStart": {
"description": "WeekStart day of the week (sunday, monday, etc)",
"type": "string"
}
}
},
"PrometheusRemoteWriteTargetJSON": {
"type": "object",
"properties": {
@ -17251,8 +17283,10 @@
},
"QueryHistoryPreference": {
"type": "object",
"title": "QueryHistoryPreference defines model for QueryHistoryPreference.",
"properties": {
"homeTab": {
"description": "HomeTab one of: '' | 'query' | 'starred';",
"type": "string"
}
}
@ -18806,38 +18840,6 @@
}
}
},
"Spec": {
"type": "object",
"title": "Spec defines model for Spec.",
"properties": {
"cookiePreferences": {
"$ref": "#/definitions/CookiePreferences"
},
"homeDashboardUID": {
"description": "UID for the home dashboard",
"type": "string"
},
"language": {
"description": "Selected language (beta)",
"type": "string"
},
"queryHistory": {
"$ref": "#/definitions/QueryHistoryPreference"
},
"theme": {
"description": "Theme light, dark, empty is default",
"type": "string"
},
"timezone": {
"description": "The timezone selection\nTODO: this should use the timezone defined in common",
"type": "string"
},
"weekStart": {
"description": "WeekStart day of the week (sunday, monday, etc)",
"type": "string"
}
}
},
"State": {
"type": "string"
},
@ -21748,7 +21750,7 @@
"getPreferencesResponse": {
"description": "(empty)",
"schema": {
"$ref": "#/definitions/Spec"
"$ref": "#/definitions/Preferences"
}
},
"getPublicAnnotationsResponse": {

View File

@ -1011,7 +1011,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Spec"
"$ref": "#/components/schemas/Preferences"
}
}
},
@ -7839,6 +7839,38 @@
},
"type": "object"
},
"Preferences": {
"description": "Spec defines user, team or org Grafana preferences",
"properties": {
"cookiePreferences": {
"$ref": "#/components/schemas/CookiePreferences"
},
"homeDashboardUID": {
"description": "UID for the home dashboard",
"type": "string"
},
"language": {
"description": "Selected language (beta)",
"type": "string"
},
"queryHistory": {
"$ref": "#/components/schemas/QueryHistoryPreference"
},
"theme": {
"description": "Theme light, dark, empty is default",
"type": "string"
},
"timezone": {
"description": "The timezone selection\nTODO: this should use the timezone defined in common",
"type": "string"
},
"weekStart": {
"description": "WeekStart day of the week (sunday, monday, etc)",
"type": "string"
}
},
"type": "object"
},
"PrometheusRemoteWriteTargetJSON": {
"properties": {
"data_source_uid": {
@ -8259,9 +8291,11 @@
"QueryHistoryPreference": {
"properties": {
"homeTab": {
"description": "HomeTab one of: '' | 'query' | 'starred';",
"type": "string"
}
},
"title": "QueryHistoryPreference defines model for QueryHistoryPreference.",
"type": "object"
},
"QueryHistoryResponse": {
@ -9812,38 +9846,6 @@
"title": "A Span defines a continuous sequence of buckets.",
"type": "object"
},
"Spec": {
"properties": {
"cookiePreferences": {
"$ref": "#/components/schemas/CookiePreferences"
},
"homeDashboardUID": {
"description": "UID for the home dashboard",
"type": "string"
},
"language": {
"description": "Selected language (beta)",
"type": "string"
},
"queryHistory": {
"$ref": "#/components/schemas/QueryHistoryPreference"
},
"theme": {
"description": "Theme light, dark, empty is default",
"type": "string"
},
"timezone": {
"description": "The timezone selection\nTODO: this should use the timezone defined in common",
"type": "string"
},
"weekStart": {
"description": "WeekStart day of the week (sunday, monday, etc)",
"type": "string"
}
},
"title": "Spec defines model for Spec.",
"type": "object"
},
"State": {
"type": "string"
},