From b232c64d9a1440d8300d0a3e48549c6cd049231a Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Tue, 12 Dec 2023 08:04:25 -0500 Subject: [PATCH] `accesscontrol` swagger: Add `global` field to `RoleDTO` type (#79351) * `accesscontrol` swagger: Add `global` field to `RoleDTO` type The field is currently added in the MarshalJSON function so it isn't reflected in the spec This PR sets the "static" version of the RoleDTO, that has the global field, as the swagger model * Revert the marshalling logic --- pkg/services/accesscontrol/models.go | 7 +++++++ public/api-enterprise-spec.json | 9 ++++++++- public/api-merged.json | 3 +++ public/openapi3.json | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pkg/services/accesscontrol/models.go b/pkg/services/accesscontrol/models.go index 14795734b73..2e848e2ab37 100644 --- a/pkg/services/accesscontrol/models.go +++ b/pkg/services/accesscontrol/models.go @@ -62,6 +62,7 @@ func (r Role) MarshalJSON() ([]byte, error) { }) } +// swagger:ignore type RoleDTO struct { Version int64 `json:"version"` UID string `xorm:"uid" json:"uid"` @@ -135,6 +136,12 @@ func (r *RoleDTO) IsExternalService() bool { return strings.HasPrefix(r.Name, ExternalServiceRolePrefix) || strings.HasPrefix(r.UID, ExternalServiceRoleUIDPrefix) } +// swagger:model RoleDTO +type RoleDTOStatic struct { + RoleDTO + Global bool `json:"global" xorm:"-"` +} + func (r RoleDTO) MarshalJSON() ([]byte, error) { type Alias RoleDTO diff --git a/public/api-enterprise-spec.json b/public/api-enterprise-spec.json index 398da1c7829..1e518971935 100644 --- a/public/api-enterprise-spec.json +++ b/public/api-enterprise-spec.json @@ -4214,7 +4214,11 @@ "type": "boolean" }, "id": { - "description": "Deprecated: use Uid instead", + "description": "Deprecated: use UID instead", + "type": "integer", + "format": "int64" + }, + "orgId": { "type": "integer", "format": "int64" }, @@ -6333,6 +6337,9 @@ "displayName": { "type": "string" }, + "global": { + "type": "boolean" + }, "group": { "type": "string" }, diff --git a/public/api-merged.json b/public/api-merged.json index e646ad46456..eb69b1bf81c 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -18142,6 +18142,9 @@ "displayName": { "type": "string" }, + "global": { + "type": "boolean" + }, "group": { "type": "string" }, diff --git a/public/openapi3.json b/public/openapi3.json index caa6c0b601d..e76cefac691 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -9073,6 +9073,9 @@ "displayName": { "type": "string" }, + "global": { + "type": "boolean" + }, "group": { "type": "string" },