Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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": {},
Expand All @@ -28,7 +28,7 @@
"version": "1.1.0-preview",
"isSingleton": false,
"configurationType": {
"$ref": "types.json#/117"
"$ref": "types.json#/116"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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."
Expand Down Expand Up @@ -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."
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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": {},
Expand All @@ -28,7 +28,7 @@
"version": "1.1.0-preview",
"isSingleton": false,
"configurationType": {
"$ref": "types.json#/113"
"$ref": "types.json#/112"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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."
Expand Down
74 changes: 45 additions & 29 deletions src/generator/src/cmd/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
Loading