feat(authz): update openapi spec (#10382)

This commit is contained in:
Vikrant Gupta
2026-02-20 22:36:33 +05:30
committed by GitHub
parent 34ba5bab28
commit 0dd42ec076
4 changed files with 38 additions and 28 deletions

View File

@@ -100,6 +100,10 @@ components:
$ref: '#/components/schemas/AuthtypesObject'
relation:
type: string
required:
- relation
- object
- authorized
type: object
AuthtypesGoogleConfig:
properties:
@@ -1672,6 +1676,9 @@ components:
$ref: '#/components/schemas/AuthtypesResource'
nullable: true
type: array
required:
- resources
- relations
type: object
RoletypesPatchableObjects:
properties:
@@ -1692,8 +1699,9 @@ components:
RoletypesPatchableRole:
properties:
description:
nullable: true
type: string
required:
- description
type: object
RoletypesPostableRole:
properties:
@@ -1722,6 +1730,11 @@ components:
updatedAt:
format: date-time
type: string
required:
- name
- description
- type
- orgId
type: object
TelemetrytypesFieldContext:
enum:

View File

@@ -131,12 +131,12 @@ export interface AuthtypesGettableTransactionDTO {
/**
* @type boolean
*/
authorized?: boolean;
object?: AuthtypesObjectDTO;
authorized: boolean;
object: AuthtypesObjectDTO;
/**
* @type string
*/
relation?: string;
relation: string;
}
export type AuthtypesGoogleConfigDTODomainToAdminEmail = {
@@ -2004,12 +2004,12 @@ export interface RoletypesGettableResourcesDTO {
* @type object
* @nullable true
*/
relations?: RoletypesGettableResourcesDTORelations;
relations: RoletypesGettableResourcesDTORelations;
/**
* @type array
* @nullable true
*/
resources?: AuthtypesResourceDTO[] | null;
resources: AuthtypesResourceDTO[] | null;
}
export interface RoletypesPatchableObjectsDTO {
@@ -2028,9 +2028,8 @@ export interface RoletypesPatchableObjectsDTO {
export interface RoletypesPatchableRoleDTO {
/**
* @type string
* @nullable true
*/
description?: string | null;
description: string;
}
export interface RoletypesPostableRoleDTO {
@@ -2053,7 +2052,7 @@ export interface RoletypesRoleDTO {
/**
* @type string
*/
description?: string;
description: string;
/**
* @type string
*/
@@ -2061,15 +2060,15 @@ export interface RoletypesRoleDTO {
/**
* @type string
*/
name?: string;
name: string;
/**
* @type string
*/
orgId?: string;
orgId: string;
/**
* @type string
*/
type?: string;
type: string;
/**
* @type string
* @format date-time

View File

@@ -26,9 +26,9 @@ type Transaction struct {
}
type GettableTransaction struct {
Relation Relation `json:"relation"`
Object Object `json:"object"`
Authorized bool `json:"authorized"`
Relation Relation `json:"relation" required:"true"`
Object Object `json:"object" required:"true"`
Authorized bool `json:"authorized" required:"true"`
}
func NewObject(resource Resource, selector Selector) (*Object, error) {

View File

@@ -69,10 +69,10 @@ type StorableRole struct {
type Role struct {
types.Identifiable
types.TimeAuditable
Name string `json:"name"`
Description string `json:"description"`
Type valuer.String `json:"type"`
OrgID valuer.UUID `json:"orgId"`
Name string `json:"name" required:"true"`
Description string `json:"description" required:"true"`
Type valuer.String `json:"type" required:"true"`
OrgID valuer.UUID `json:"orgId" required:"true"`
}
type PostableRole struct {
@@ -81,7 +81,7 @@ type PostableRole struct {
}
type PatchableRole struct {
Description *string `json:"description"`
Description string `json:"description" required:"true"`
}
type PatchableObjects struct {
@@ -90,8 +90,8 @@ type PatchableObjects struct {
}
type GettableResources struct {
Resources []*authtypes.Resource `json:"resources"`
Relations map[authtypes.Type][]authtypes.Relation `json:"relations"`
Resources []*authtypes.Resource `json:"resources" required:"true"`
Relations map[authtypes.Type][]authtypes.Relation `json:"relations" required:"true"`
}
func NewStorableRoleFromRole(role *Role) *StorableRole {
@@ -149,15 +149,13 @@ func NewGettableResources(resources []*authtypes.Resource) *GettableResources {
}
}
func (role *Role) PatchMetadata(description *string) error {
func (role *Role) PatchMetadata(description string) error {
err := role.CanEditDelete()
if err != nil {
return err
}
if description != nil {
role.Description = *description
}
role.Description = description
role.UpdatedAt = time.Now()
return nil
}
@@ -222,7 +220,7 @@ func (role *PostableRole) UnmarshalJSON(data []byte) error {
func (role *PatchableRole) UnmarshalJSON(data []byte) error {
type shadowPatchableRole struct {
Description *string `json:"description"`
Description string `json:"description"`
}
var shadowRole shadowPatchableRole
@@ -230,7 +228,7 @@ func (role *PatchableRole) UnmarshalJSON(data []byte) error {
return err
}
if shadowRole.Description == nil {
if shadowRole.Description == "" {
return errors.New(errors.TypeInvalidInput, ErrCodeRoleEmptyPatch, "empty role patch request received, description must be present")
}