From 17c8285154afdf644cd95a0a45cc06d6d59db003 Mon Sep 17 00:00:00 2001 From: taofeeko Date: Thu, 19 Feb 2026 11:45:49 -0800 Subject: [PATCH] Resolving referencing error --- .../beta/1.1.0-preview/index.json | 16 ++-- .../beta/1.1.0-preview/types.json | 53 +++++++------ .../v1.0/1.1.0-preview/index.json | 16 ++-- .../v1.0/1.1.0-preview/types.json | 25 +------ src/generator/src/cmd/generate.ts | 74 +++++++++++-------- 5 files changed, 91 insertions(+), 93 deletions(-) diff --git a/generated/microsoftgraph/microsoft.graph/beta/1.1.0-preview/index.json b/generated/microsoftgraph/microsoft.graph/beta/1.1.0-preview/index.json index 590812d..68ab173 100644 --- a/generated/microsoftgraph/microsoft.graph/beta/1.1.0-preview/index.json +++ b/generated/microsoftgraph/microsoft.graph/beta/1.1.0-preview/index.json @@ -1,25 +1,25 @@ { "resources": { "Microsoft.Graph/groups@beta": { - "$ref": "types.json#/23" + "$ref": "types.json#/22" }, "Microsoft.Graph/applications@beta": { - "$ref": "types.json#/79" + "$ref": "types.json#/78" }, "Microsoft.Graph/servicePrincipals@beta": { - "$ref": "types.json#/97" + "$ref": "types.json#/96" }, "Microsoft.Graph/applications/federatedIdentityCredentials@beta": { - "$ref": "types.json#/103" + "$ref": "types.json#/102" }, "Microsoft.Graph/oauth2PermissionGrants@beta": { - "$ref": "types.json#/107" + "$ref": "types.json#/106" }, "Microsoft.Graph/appRoleAssignedTo@beta": { - "$ref": "types.json#/111" + "$ref": "types.json#/110" }, "Microsoft.Graph/users@beta": { - "$ref": "types.json#/116" + "$ref": "types.json#/115" } }, "resourceFunctions": {}, @@ -28,7 +28,7 @@ "version": "1.1.0-preview", "isSingleton": false, "configurationType": { - "$ref": "types.json#/117" + "$ref": "types.json#/116" } } } \ No newline at end of file diff --git a/generated/microsoftgraph/microsoft.graph/beta/1.1.0-preview/types.json b/generated/microsoftgraph/microsoft.graph/beta/1.1.0-preview/types.json index 0f7e049..54f3dce 100644 --- a/generated/microsoftgraph/microsoft.graph/beta/1.1.0-preview/types.json +++ b/generated/microsoftgraph/microsoft.graph/beta/1.1.0-preview/types.json @@ -445,26 +445,6 @@ } } }, - { - "$type": "ObjectType", - "name": "MicrosoftGraphRelationshipMember", - "properties": { - "id": { - "type": { - "$ref": "#/0" - }, - "flags": 1, - "description": "The unique identifier of the relationship member." - }, - "type": { - "type": { - "$ref": "#/0" - }, - "flags": 2, - "description": "The type of the relationship member (e.g., user, group, servicePrincipal). This is a read-only property populated by the system." - } - } - }, { "$type": "ObjectType", "name": "MicrosoftGraphRelationship", @@ -478,10 +458,7 @@ }, "relationships": { "type": { - "$type": "ArrayType", - "itemType": { - "$ref": "#/16" - } + "$ref": "#/21" }, "flags": 1, "description": "The list of relationship members with their IDs and types." @@ -527,6 +504,34 @@ }, "flags": 2, "description": "The type of the relationship member (e.g., user, group, servicePrincipal). This is a read-only property populated by the system." + }, + "displayName": { + "type": { + "$ref": "#/0" + }, + "flags": 2, + "description": "The display name of the relationship member. This is a read-only property populated by the system." + }, + "userPrincipalName": { + "type": { + "$ref": "#/0" + }, + "flags": 2, + "description": "The user principal name (UPN) of the relationship member. This field is only populated for user objects and will be null/undefined for other object types (groups, service principals, etc.). This is a read-only property populated by the system." + }, + "appId": { + "type": { + "$ref": "#/0" + }, + "flags": 2, + "description": "The application ID of the relationship member. This field is only populated for service principal objects and will be null/undefined for other object types (users, groups, etc.). This is a read-only property populated by the system." + }, + "uniqueName": { + "type": { + "$ref": "#/0" + }, + "flags": 2, + "description": "A unique name that can be used to reference this relationship member in templates. This is a read-only property populated by the system." } } }, diff --git a/generated/microsoftgraph/microsoft.graph/v1.0/1.1.0-preview/index.json b/generated/microsoftgraph/microsoft.graph/v1.0/1.1.0-preview/index.json index 9314aa4..fbbbc7a 100644 --- a/generated/microsoftgraph/microsoft.graph/v1.0/1.1.0-preview/index.json +++ b/generated/microsoftgraph/microsoft.graph/v1.0/1.1.0-preview/index.json @@ -1,25 +1,25 @@ { "resources": { "Microsoft.Graph/groups@v1.0": { - "$ref": "types.json#/18" + "$ref": "types.json#/17" }, "Microsoft.Graph/applications@v1.0": { - "$ref": "types.json#/76" + "$ref": "types.json#/75" }, "Microsoft.Graph/servicePrincipals@v1.0": { - "$ref": "types.json#/94" + "$ref": "types.json#/93" }, "Microsoft.Graph/applications/federatedIdentityCredentials@v1.0": { - "$ref": "types.json#/99" + "$ref": "types.json#/98" }, "Microsoft.Graph/oauth2PermissionGrants@v1.0": { - "$ref": "types.json#/103" + "$ref": "types.json#/102" }, "Microsoft.Graph/appRoleAssignedTo@v1.0": { - "$ref": "types.json#/107" + "$ref": "types.json#/106" }, "Microsoft.Graph/users@v1.0": { - "$ref": "types.json#/112" + "$ref": "types.json#/111" } }, "resourceFunctions": {}, @@ -28,7 +28,7 @@ "version": "1.1.0-preview", "isSingleton": false, "configurationType": { - "$ref": "types.json#/113" + "$ref": "types.json#/112" } } } \ No newline at end of file diff --git a/generated/microsoftgraph/microsoft.graph/v1.0/1.1.0-preview/types.json b/generated/microsoftgraph/microsoft.graph/v1.0/1.1.0-preview/types.json index f83fb4a..8b4d73f 100644 --- a/generated/microsoftgraph/microsoft.graph/v1.0/1.1.0-preview/types.json +++ b/generated/microsoftgraph/microsoft.graph/v1.0/1.1.0-preview/types.json @@ -356,26 +356,6 @@ "$ref": "#/9" } }, - { - "$type": "ObjectType", - "name": "MicrosoftGraphRelationshipMember", - "properties": { - "id": { - "type": { - "$ref": "#/0" - }, - "flags": 1, - "description": "The unique identifier of the relationship member." - }, - "type": { - "type": { - "$ref": "#/0" - }, - "flags": 2, - "description": "The type of the relationship member (e.g., user, group, servicePrincipal). This is a read-only property populated by the system." - } - } - }, { "$type": "ObjectType", "name": "MicrosoftGraphRelationship", @@ -389,10 +369,7 @@ }, "relationships": { "type": { - "$type": "ArrayType", - "itemType": { - "$ref": "#/11" - } + "$ref": "#/16" }, "flags": 1, "description": "The list of relationship members with their IDs and types." diff --git a/src/generator/src/cmd/generate.ts b/src/generator/src/cmd/generate.ts index 3805ac0..7f840b5 100644 --- a/src/generator/src/cmd/generate.ts +++ b/src/generator/src/cmd/generate.ts @@ -272,36 +272,52 @@ async function buildTypeIndex(logger: ILogger, baseDir: string, apiVersion: ApiV const isEnhanced = isEnhancedRelationshipVersion(apiVersion, extensionVersion); if (isEnhanced) { - // Add RelationshipMember type before MicrosoftGraphRelationship - const relationshipMemberType = { - $type: TypeBaseKind.ObjectType, - name: "MicrosoftGraphRelationshipMember", - properties: { - id: { - type: { $ref: "#/0" }, // StringType - flags: 1, // Required - description: "The unique identifier of the relationship member." - }, - type: { - type: { $ref: "#/0" }, // StringType - flags: 2, // ReadOnly - description: "The type of the relationship member (e.g., user, group, servicePrincipal). This is a read-only property populated by the system." - } + // Find the existing autorest-generated MicrosoftGraphRelationshipMember type + const relationshipMemberIndex = contentTypes.findIndex(type => type["$type"] === TypeBaseKind.ObjectType && type["name"] === 'MicrosoftGraphRelationshipMember'); + + if (relationshipMemberIndex !== -1) { + // Ensure the richer fields are present on the MicrosoftGraphRelationshipMember type + const memberType = contentTypes[relationshipMemberIndex]; + if (!memberType.properties.displayName) { + memberType.properties.displayName = { + type: { $ref: "#/0" }, + flags: 2, + description: "The display name of the relationship member. This is a read-only property populated by the system." + }; } - }; - - // Insert before MicrosoftGraphRelationship - const relationshipIndex = contentTypes.findIndex(type => type.name === 'MicrosoftGraphRelationship'); - contentTypes.splice(relationshipIndex, 0, relationshipMemberType); - - // Update relationships property to reference RelationshipMember array - const updatedRelationshipType = { ...relationshipType }; - updatedRelationshipType.properties.relationships.type = { - $type: "ArrayType", - itemType: { $ref: `#/${relationshipIndex}` } // Reference to RelationshipMember - }; - updatedRelationshipType.properties.relationships.description = "The list of relationship members with their IDs and types."; - contentTypes[relationshipIndex + 1] = updatedRelationshipType; + if (!memberType.properties.userPrincipalName) { + memberType.properties.userPrincipalName = { + type: { $ref: "#/0" }, + flags: 2, + description: "The user principal name (UPN) of the relationship member. This field is only populated for user objects and will be null/undefined for other object types (groups, service principals, etc.). This is a read-only property populated by the system." + }; + } + if (!memberType.properties.appId) { + memberType.properties.appId = { + type: { $ref: "#/0" }, + flags: 2, + description: "The application ID of the relationship member. This field is only populated for service principal objects and will be null/undefined for other object types (users, groups, etc.). This is a read-only property populated by the system." + }; + } + if (!memberType.properties.uniqueName) { + memberType.properties.uniqueName = { + type: { $ref: "#/0" }, + flags: 2, + description: "A unique name that can be used to reference this relationship member in templates. This is a read-only property populated by the system." + }; + } + + // Find the existing ArrayType that references the MicrosoftGraphRelationshipMember + const memberArrayIndex = contentTypes.findIndex(type => type["$type"] === "ArrayType" && type["itemType"]?.["$ref"] === `#/${relationshipMemberIndex}`); + + if (memberArrayIndex !== -1) { + // Update relationships property to reference the ArrayType of MicrosoftGraphRelationshipMember + relationshipType.properties.relationships.type = { + $ref: `#/${memberArrayIndex}` + }; + relationshipType.properties.relationships.description = "The list of relationship members with their IDs and types."; + } + } } const relationshipSemanticsType = relationshipType.properties['relationshipSemantics'];