diff --git a/pkg/services/ngalert/api/tooling/Makefile b/pkg/services/ngalert/api/tooling/Makefile index 099b532b5cf..4a66f5176d3 100644 --- a/pkg/services/ngalert/api/tooling/Makefile +++ b/pkg/services/ngalert/api/tooling/Makefile @@ -1,3 +1,5 @@ +include ../../../../../.citools/Variables.mk + .DEFAULT_GOAL := openapi API_DIR = definitions @@ -6,8 +8,7 @@ GO_PKG_FILES = $(shell find $(API_DIR) -name *.go -print) PATH_DOWN = pkg/services/ngalert/api/tooling PATH_UP = ../../../../.. -GO ?= $(shell which go) -SWAGGER = GODEBUG=gotypesalias=0 $(GO) tool swagger +SWAGGER = GODEBUG=gotypesalias=0 $(swagger) .DEFAULT_GOAL := all @@ -29,6 +30,12 @@ endif spec.json spec-stable.json: $(GO_PKG_FILES) SWAGGER_GENERATE_EXTENSION=false $(SWAGGER) generate spec -m -w $(API_DIR) -o spec.json && SWAGGER_GENERATE_EXTENSION=false $(SWAGGER) generate spec -m --include-tag=stable -o spec-stable.json +# Prometheus URL type collides with the net/url.URL type, so we need to fix the spec if the descriptions are not correct +# to make the spec generation consistent. +fix-spec: + sed $(SED_INPLACE) -e 's/A URL represents a parsed URL (technically, a URI reference)./URL is a custom URL type that allows validation at configuration load time./' spec.json spec-stable.json + sed $(SED_INPLACE) -e '/The general form represented is:\\n\\n\[scheme:\]\[\/\/\[userinfo@\]host\]\[\/\]path\[?query\]\[#fragment\]/d' spec.json spec-stable.json + post.json: spec.json go run cmd/clean-swagger/main.go -if $(<) -of $@ @@ -76,4 +83,4 @@ serve-stable: api.json gen: swagger-codegen-api fix copy-files clean-go -all: clean spec.json spec-stable.json post.json api.json gen +all: clean spec.json spec-stable.json fix-spec post.json api.json gen diff --git a/pkg/services/ngalert/api/tooling/api.json b/pkg/services/ngalert/api/tooling/api.json index 1c2ba6ab7b4..2714cbb9e3a 100644 --- a/pkg/services/ngalert/api/tooling/api.json +++ b/pkg/services/ngalert/api/tooling/api.json @@ -4932,6 +4932,7 @@ "type": "object" }, "alertGroups": { + "description": "AlertGroups alert groups", "items": { "$ref": "#/definitions/alertGroup", "type": "object" @@ -5218,6 +5219,7 @@ "type": "object" }, "gettableSilences": { + "description": "GettableSilences gettable silences", "items": { "$ref": "#/definitions/gettableSilence", "type": "object" diff --git a/pkg/services/ngalert/api/tooling/definitions/alertmanager.go b/pkg/services/ngalert/api/tooling/definitions/alertmanager.go index 9e922024312..d1d16790ad0 100644 --- a/pkg/services/ngalert/api/tooling/definitions/alertmanager.go +++ b/pkg/services/ngalert/api/tooling/definitions/alertmanager.go @@ -498,6 +498,8 @@ type PostSilencesOKBody struct { // vendored from "github.com/prometheus/alertma SilenceID string `json:"silenceID,omitempty"` } +// GettableSilences gettable silences +// // swagger:model gettableSilences type GettableSilences = amv2.GettableSilences @@ -552,11 +554,15 @@ func (s GettableGrafanaSilence) MarshalJSON() ([]byte, error) { // swagger:model gettableGrafanaSilences type GettableGrafanaSilences []*GettableGrafanaSilence +// GettableAlerts gettable alerts +// // swagger:model gettableAlerts type GettableAlerts = amv2.GettableAlerts type GettableAlert = amv2.GettableAlert +// AlertGroups alert groups +// // swagger:model alertGroups type AlertGroups = amv2.AlertGroups diff --git a/pkg/services/ngalert/api/tooling/post.json b/pkg/services/ngalert/api/tooling/post.json index edc562c0ae0..da8a692dc90 100644 --- a/pkg/services/ngalert/api/tooling/post.json +++ b/pkg/services/ngalert/api/tooling/post.json @@ -4636,7 +4636,6 @@ "type": "object" }, "URL": { - "description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nThe Host field contains the host and port subcomponents of the URL.\nWhen the port is present, it is separated from the host with a colon.\nWhen the host is an IPv6 address, it must be enclosed in square brackets:\n\"[fe80::1]:80\". The [net.JoinHostPort] function combines a host and port\ninto a string suitable for the Host field, adding square brackets to\nthe host when necessary.\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use the [URL.EscapedPath] method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.", "properties": { "ForceQuery": { "type": "boolean" @@ -4672,7 +4671,7 @@ "$ref": "#/definitions/Userinfo" } }, - "title": "A URL represents a parsed URL (technically, a URI reference).", + "title": "URL is a custom URL type that allows validation at configuration load time.", "type": "object" }, "UpdateNamespaceRulesRequest": { @@ -4933,6 +4932,7 @@ "type": "object" }, "alertGroups": { + "description": "AlertGroups alert groups", "items": { "$ref": "#/definitions/alertGroup", "type": "object" @@ -5094,6 +5094,7 @@ "type": "object" }, "gettableAlerts": { + "description": "GettableAlerts gettable alerts", "items": { "$ref": "#/definitions/gettableAlert", "type": "object" diff --git a/pkg/services/ngalert/api/tooling/spec.json b/pkg/services/ngalert/api/tooling/spec.json index 8d4ba4c5e03..0e2031fb36d 100644 --- a/pkg/services/ngalert/api/tooling/spec.json +++ b/pkg/services/ngalert/api/tooling/spec.json @@ -8809,9 +8809,8 @@ } }, "URL": { - "description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nThe Host field contains the host and port subcomponents of the URL.\nWhen the port is present, it is separated from the host with a colon.\nWhen the host is an IPv6 address, it must be enclosed in square brackets:\n\"[fe80::1]:80\". The [net.JoinHostPort] function combines a host and port\ninto a string suitable for the Host field, adding square brackets to\nthe host when necessary.\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use the [URL.EscapedPath] method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.", "type": "object", - "title": "A URL represents a parsed URL (technically, a URI reference).", + "title": "URL is a custom URL type that allows validation at configuration load time.", "properties": { "ForceQuery": { "type": "boolean" @@ -9106,6 +9105,7 @@ } }, "alertGroups": { + "description": "AlertGroups alert groups", "type": "array", "items": { "type": "object", @@ -9267,6 +9267,7 @@ } }, "gettableAlerts": { + "description": "GettableAlerts gettable alerts", "type": "array", "items": { "type": "object", diff --git a/public/api-merged.json b/public/api-merged.json index b7e77910163..56f42df789e 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -22999,6 +22999,7 @@ } }, "alertGroups": { + "description": "AlertGroups alert groups", "type": "array", "items": { "type": "object", @@ -23328,6 +23329,7 @@ } }, "gettableSilences": { + "description": "GettableSilences gettable silences", "type": "array", "items": { "type": "object", diff --git a/public/openapi3.json b/public/openapi3.json index ca7f23f4414..f32b82e15d3 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -12974,6 +12974,7 @@ "type": "object" }, "alertGroups": { + "description": "AlertGroups alert groups", "items": { "$ref": "#/components/schemas/alertGroup" }, @@ -13301,6 +13302,7 @@ "type": "object" }, "gettableSilences": { + "description": "GettableSilences gettable silences", "items": { "$ref": "#/components/schemas/gettableSilence" },