Skip to content

Commit 6d84fdf

Browse files
committed
Reviewed snippet generator
1 parent 9ccf2c2 commit 6d84fdf

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tools/ExamplesGenerator.ps1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ function Update-ExampleFile {
332332
$Code = "``````powershell`r$CodeValue`r`n``````"
333333

334334
$TotalText = "$TitleValue`r`n`n$Code`r`n$Description`r`n"
335+
if($GraphProfile -eq "beta"){
336+
#Replace examples to match the new beta naming convention
337+
$TotalText = $TotalText.Replace("-Mg", "-MgBeta")
338+
$TotalText = $TotalText.Replace("Microsoft.Graph", "Microsoft.Graph.Beta")
339+
}
335340
Add-Content -Path $ExampleFile -Value $TotalText
336341
}else{
337342
$WrongExamplesCount++
@@ -340,9 +345,6 @@ function Update-ExampleFile {
340345
}
341346
}
342347
$PatternToSearch = "Import-Module Microsoft.Graph.$Module"
343-
if($GraphProfile -eq "beta"){
344-
$PatternToSearch = "Import-Module Microsoft.Graph.Beta.$Module"
345-
}
346348
if(($Content | Select-String -pattern $SearchText) -and ($Content | Select-String -pattern "This example shows")){
347349
$ContainsPatternToSearch = $False
348350
foreach($List in $ExampleList){
@@ -359,6 +361,11 @@ function Update-ExampleFile {
359361
$Code = "``````powershell`r$CodeValue`r`n``````"
360362

361363
$TotalText = "$TitleValue`r`n`n$Code`r`n$Description`r`n"
364+
if($GraphProfile -eq "beta"){
365+
#Replace examples to match the new beta naming convention
366+
$TotalText = $TotalText.Replace("-Mg", "-MgBeta")
367+
$TotalText = $TotalText.Replace("Microsoft.Graph", "Microsoft.Graph.Beta")
368+
}
362369
Add-Content -Path $ExampleFile -Value $TotalText
363370
}
364371

@@ -432,7 +439,7 @@ if ($ModulesToGenerate.Count -eq 0) {
432439
[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable
433440
$ModulesToGenerate = $ModuleMapping.Keys
434441
}
435-
Start-Generator -ModulesToGenerate $ModulesToGenerate -GenerationMode "auto"
442+
#Start-Generator -ModulesToGenerate $ModulesToGenerate -GenerationMode "auto"
436443

437444
#Comment the above and uncomment the below start command, if you manually want to manually pass ExternalDocs url.
438445
#This is for scenarios where the correponding external docs url to the uri path gotten from Find-MgGraph command, is missing on the openapi.yml file for a particular module.
@@ -448,5 +455,5 @@ Start-Generator -ModulesToGenerate $ModulesToGenerate -GenerationMode "auto"
448455
#Start-Generator -GenerationMode "manual" -ManualExternalDocsUrl "https://docs.microsoft.com/graph/api/user-get?view=graph-rest-1.0" -GraphCommand "Get-MgUser" -GraphModule "Users" -Profile "v1.0"
449456

450457
#3. Test for updates from api reference
451-
#Start-Generator -GenerationMode "manual" -ManualExternalDocsUrl "https://docs.microsoft.com/graph/api/serviceprincipal-post-approleassignedto?view=graph-rest-1.0" -GraphCommand "New-MgServicePrincipalAppRoleAssignedTo" -GraphModule "Applications" -Profile "v1.0"
452-
Write-Host -ForegroundColor Green "-------------Done-------------"
458+
Start-Generator -GenerationMode "manual" -ManualExternalDocsUrl "https://docs.microsoft.com/graph/api/serviceprincipal-post-approleassignedto?view=graph-rest-beta" -GraphCommand "New-MgBetaServicePrincipalAppRoleAssignedTo" -GraphModule "Applications" -Profile "beta"
459+
#Write-Host -ForegroundColor Green "-------------Done-------------"

0 commit comments

Comments
 (0)