From cd584e9261f6e8e5bc35c0ff326550bb5b1a010f Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Mon, 4 Dec 2023 11:20:13 -0500 Subject: [PATCH] Swagger: Fix `getLibraryElementByName` response (#78221) It returns an array of library elements, not a single one. This has been tested by generating the OpenAPI client and using it in Terraform --- pkg/services/libraryelements/api.go | 8 +++++++- public/api-enterprise-spec.json | 18 ++++++++++++++++++ public/api-merged.json | 20 +++++++++++++++++++- public/openapi3.json | 24 +++++++++++++++++++++++- 4 files changed, 67 insertions(+), 3 deletions(-) diff --git a/pkg/services/libraryelements/api.go b/pkg/services/libraryelements/api.go index 35131cf188f..1cf3bd012a7 100644 --- a/pkg/services/libraryelements/api.go +++ b/pkg/services/libraryelements/api.go @@ -270,7 +270,7 @@ func (l *LibraryElementService) getConnectionsHandler(c *contextmodel.ReqContext // Returns a library element with the given name. // // Responses: -// 200: getLibraryElementResponse +// 200: getLibraryElementArrayResponse // 401: unauthorisedError // 404: notFoundError // 500: internalServerError @@ -448,6 +448,12 @@ type GetLibraryElementResponse struct { Body model.LibraryElementResponse `json:"body"` } +// swagger:response getLibraryElementArrayResponse +type GetLibraryElementArrayResponse struct { + // in: body + Body model.LibraryElementArrayResponse `json:"body"` +} + // swagger:response getLibraryElementConnectionsResponse type GetLibraryElementConnectionsResponse struct { // in: body diff --git a/public/api-enterprise-spec.json b/public/api-enterprise-spec.json index 225181bc987..398da1c7829 100644 --- a/public/api-enterprise-spec.json +++ b/public/api-enterprise-spec.json @@ -4764,6 +4764,18 @@ } } }, + "LibraryElementArrayResponse": { + "type": "object", + "title": "LibraryElementArrayResponse is a response struct for an array of LibraryElementDTO.", + "properties": { + "result": { + "type": "array", + "items": { + "$ref": "#/definitions/LibraryElementDTO" + } + } + } + }, "LibraryElementConnectionDTO": { "type": "object", "title": "LibraryElementConnectionDTO is the frontend DTO for element connections.", @@ -8480,6 +8492,12 @@ "$ref": "#/definitions/GetHomeDashboardResponse" } }, + "getLibraryElementArrayResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/LibraryElementArrayResponse" + } + }, "getLibraryElementConnectionsResponse": { "description": "", "schema": { diff --git a/public/api-merged.json b/public/api-merged.json index 8d4af17742b..73535fbfb23 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -6017,7 +6017,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getLibraryElementResponse" + "$ref": "#/responses/getLibraryElementArrayResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -15313,6 +15313,18 @@ } } }, + "LibraryElementArrayResponse": { + "type": "object", + "title": "LibraryElementArrayResponse is a response struct for an array of LibraryElementDTO.", + "properties": { + "result": { + "type": "array", + "items": { + "$ref": "#/definitions/LibraryElementDTO" + } + } + } + }, "LibraryElementConnectionDTO": { "type": "object", "title": "LibraryElementConnectionDTO is the frontend DTO for element connections.", @@ -21654,6 +21666,12 @@ "$ref": "#/definitions/GetHomeDashboardResponse" } }, + "getLibraryElementArrayResponse": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/LibraryElementArrayResponse" + } + }, "getLibraryElementConnectionsResponse": { "description": "(empty)", "schema": { diff --git a/public/openapi3.json b/public/openapi3.json index 128be4ab697..d4757ae03cb 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -862,6 +862,16 @@ }, "description": "(empty)" }, + "getLibraryElementArrayResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LibraryElementArrayResponse" + } + } + }, + "description": "(empty)" + }, "getLibraryElementConnectionsResponse": { "content": { "application/json": { @@ -6321,6 +6331,18 @@ }, "type": "object" }, + "LibraryElementArrayResponse": { + "properties": { + "result": { + "items": { + "$ref": "#/components/schemas/LibraryElementDTO" + }, + "type": "array" + } + }, + "title": "LibraryElementArrayResponse is a response struct for an array of LibraryElementDTO.", + "type": "object" + }, "LibraryElementConnectionDTO": { "properties": { "connectionId": { @@ -18659,7 +18681,7 @@ ], "responses": { "200": { - "$ref": "#/components/responses/getLibraryElementResponse" + "$ref": "#/components/responses/getLibraryElementArrayResponse" }, "401": { "$ref": "#/components/responses/unauthorisedError"