@@ -27,6 +27,7 @@ prefix: Mg
2727module-name : Microsoft.Graph.$(service-name)
2828subject-prefix : $(service-name)
2929namespace : Microsoft.Graph.PowerShell
30+ sanitize-names : false
3031` ` `
3132
3233> Folders
@@ -51,7 +52,9 @@ directive:
5152 - microsoft.graph.post
5253 - microsoft.graph.sectionGroup
5354 - microsoft.graph.team
54- # Formart cmdlet response.
55+ - microsoft.graph.recipient
56+
57+ # Format cmdlet response.
5558 - where :
5659 model-name : MicrosoftGraphUser
5760 set :
@@ -289,4 +292,41 @@ directive:
289292 set :
290293 verb : Get
291294 subject : $2$1
295+ # Add AfterToJson
296+ - from : source-file-csharp
297+ where : $
298+ transform : >
299+ if (!$documentPath.match(/generated%5Capi%5CModels%5CMicrosoftGraph\w*.json.cs/gm))
300+ {
301+ return $;
302+ } else {
303+ let afterJsonDeclarationRegex = /(^\s*)(partial\s*void\s*AfterFromJson\s*\(Microsoft.Graph.PowerShell.Runtime.Json.JsonObject\s*json\s*\);$)/gm
304+ $ = $.replace(afterJsonDeclarationRegex, '$1$2\n$1partial void AfterToJson(ref Microsoft.Graph.PowerShell.Runtime.Json.JsonObject container, Microsoft.Graph.PowerShell.Runtime.SerializationMode serializationMode);\n');
305+ let afterJsonRegex = /(^\s*)(AfterToJson\(ref\s*container\s*\);$)/gm
306+ $ = $.replace(afterJsonRegex, '$1$2\n$1AfterToJson(ref container, serializationMode);\n');
307+ return $;
308+ }
309+ - from : source-file-csharp
310+ where : $
311+ transform : >
312+ if (!$documentPath.match(/generated%5Capi%5CModels%5CMicrosoftGraph\w*.cs/gm))
313+ {
314+ return $;
315+ } else {
316+ let regexPattern = /^\s*public\s*partial\s*class\s*MicrosoftGraph(?<EntityName>.*):$/gm;
317+ let regexArray;
318+ while ((regexArray = regexPattern.exec($)) !== null) {
319+ if (regexArray['groups'] != null)
320+ {
321+ let EntityName = regexArray['groups'].EntityName.trim();
322+ let newEntityId = EntityName + 'Id';
323+ let newEntityIdPropRegex = new RegExp("^\\s*public\\s*string\\s*"+newEntityId+"\\.*","gm");
324+ let existingIdPropRegex = /(^\s*)(public\s*string\s*Id\s.*)/gm;
325+ if ((!$.match(newEntityIdPropRegex)) && $.match(existingIdPropRegex) && (newEntityId != "EntityId") && (newEntityId != "BaseItemId")) {
326+ $ = $.replace(existingIdPropRegex, '$1$2\n\n$1partial void AfterToJson(ref Microsoft.Graph.PowerShell.Runtime.Json.JsonObject container, Microsoft.Graph.PowerShell.Runtime.SerializationMode serializationMode)\n$1{\n$1\tif (serializationMode == Microsoft.Graph.PowerShell.Runtime.SerializationMode.IncludeAll) {\n$1\t\tAddIf(null != this.Id ? (Microsoft.Graph.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.PowerShell.Runtime.Json.JsonString(this.Id) : null, "'+ EntityName.toLowerCase() +'-id", container.Add);\n$1\t}\n$1}');
327+ }
328+ }
329+ }
330+ return $;
331+ }
292332` ` `
0 commit comments