Skip to content

Commit 3add748

Browse files
author
George Ndungu
committed
Call ForceRefresh for first request only.
1 parent ff24ec1 commit 3add748

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

tools/DownloadOpenApiDoc.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ Param(
22
[string] $ModuleName,
33
[string] $ModuleRegex,
44
[string] $OpenApiDocOutput,
5-
[string] $GraphVersion
5+
[string] $GraphVersion,
6+
[int] $RequestCount
67
)
78

8-
if(-not (Test-Path $OpenApiDocOutput)) {
9+
if (-not (Test-Path $OpenApiDocOutput)) {
910
New-Item -Path $OpenApiDocOutput -Type Directory
1011
}
11-
12+
1213
$OpenApiBaseUrl = "https://graphexplorerapi.azurewebsites.net"
1314
$OpenApiServiceUrl = ("$OpenApiBaseUrl/`$openapi?tags={0}&title=$ModuleName&openapiversion=3&style=Powershell&graphVersion=$GraphVersion" -f $ModuleRegex)
15+
if ($RequestCount -eq 0) {
16+
$OpenApiServiceUrl = "$OpenApiServiceUrl&forceRefresh=true"
17+
}
1418

15-
Write-Host -ForegroundColor Green "Downloading OpenAPI doc for '$ModuleName' module: $OpenApiServiceUrl"
19+
Write-Host -ForegroundColor Green "[$RequestCount] Downloading OpenAPI doc for '$ModuleName' module: $OpenApiServiceUrl"
1620
Invoke-WebRequest $OpenApiServiceUrl -OutFile "$OpenApiDocOutput\$ModuleName.yml"

tools/UpdateOpenApi.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ if (-not (Test-Path $ModuleMappingConfigPath)) {
2929
}
3030

3131
[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable
32-
$ModuleMapping.Keys | ForEach-Object {
32+
$ModuleMapping.Keys | ForEach-Object -Begin { $RequestCount = 0 } -End { Write-Host -ForeGroundColor Green "Requests: $RequestCount" } -Process {
3333
$ModuleName = $_
34-
35-
try {
36-
# Download OpenAPI document for module.
37-
& $DownloadOpenApiDocPS1 -ModuleName $ModuleName -ModuleRegex $ModuleMapping[$ModuleName] -OpenApiDocOutput $OpenApiDocOutput -GraphVersion $GraphVersion
38-
}
39-
catch {
40-
Write-Error $_.Exception
41-
}
34+
try {
35+
# Download OpenAPI document for module.
36+
& $DownloadOpenApiDocPS1 -ModuleName $ModuleName -ModuleRegex $ModuleMapping[$ModuleName] -OpenApiDocOutput $OpenApiDocOutput -GraphVersion $GraphVersion -RequestCount $RequestCount
37+
}
38+
catch {
39+
Write-Error $_.Exception
40+
}
41+
$RequestCount = $RequestCount + 1
4242
}
4343

4444

0 commit comments

Comments
 (0)