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
40,108 changes: 40,108 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Applications.yml

Large diffs are not rendered by default.

11,807 changes: 11,807 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/BackupRestore.yml

Large diffs are not rendered by default.

11,362 changes: 11,362 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Bookings.yml

Large diffs are not rendered by default.

16,769 changes: 16,769 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Calendar.yml

Large diffs are not rendered by default.

1,568 changes: 1,568 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/ChangeNotifications.yml

Large diffs are not rendered by default.

15,050 changes: 15,050 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/CloudCommunications.yml

Large diffs are not rendered by default.

24,214 changes: 24,214 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Compliance.yml

Large diffs are not rendered by default.

3,027 changes: 3,027 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/ConfigurationManagement.yml

Large diffs are not rendered by default.

1,995 changes: 1,995 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/CrossDeviceExperiences.yml

Large diffs are not rendered by default.

30,577 changes: 30,577 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/DeviceManagement.Administration.yml

Large diffs are not rendered by default.

3,885 changes: 3,885 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/DeviceManagement.Enrollment.yml

Large diffs are not rendered by default.

435 changes: 435 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/DeviceManagement.Functions.yml

Large diffs are not rendered by default.

37,818 changes: 37,818 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/DeviceManagement.yml

Large diffs are not rendered by default.

27,394 changes: 27,394 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Devices.CloudPrint.yml

Large diffs are not rendered by default.

49,542 changes: 49,542 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Devices.CorporateManagement.yml

Large diffs are not rendered by default.

3,164 changes: 3,164 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Devices.ServiceAnnouncement.yml

Large diffs are not rendered by default.

2,692 changes: 2,692 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/DirectoryObjects.yml

Large diffs are not rendered by default.

37,893 changes: 37,893 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Education.yml

Large diffs are not rendered by default.

84,512 changes: 84,512 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Files.yml

Large diffs are not rendered by default.

37,233 changes: 37,233 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Groups.yml

Large diffs are not rendered by default.

46,847 changes: 46,847 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Identity.DirectoryManagement.yml

Large diffs are not rendered by default.

80,677 changes: 80,677 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Identity.Governance.yml

Large diffs are not rendered by default.

2,872 changes: 2,872 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Identity.Partner.yml

Large diffs are not rendered by default.

48,672 changes: 48,672 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Identity.SignIns.yml

Large diffs are not rendered by default.

6,694 changes: 6,694 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Mail.yml

Large diffs are not rendered by default.

17,257 changes: 17,257 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Notes.yml

Large diffs are not rendered by default.

1,810 changes: 1,810 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/People.yml

Large diffs are not rendered by default.

3,990 changes: 3,990 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/PersonalContacts.yml

Large diffs are not rendered by default.

8,842 changes: 8,842 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Planner.yml

Large diffs are not rendered by default.

11,027 changes: 11,027 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Reports.yml

Large diffs are not rendered by default.

1,566 changes: 1,566 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/SchemaExtensions.yml

Large diffs are not rendered by default.

5,072 changes: 5,072 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Search.yml

Large diffs are not rendered by default.

54,182 changes: 54,182 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Security.yml

Large diffs are not rendered by default.

83,940 changes: 83,940 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Sites.yml

Large diffs are not rendered by default.

67,754 changes: 67,754 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Teams.yml

Large diffs are not rendered by default.

23,555 changes: 23,555 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Users.Actions.yml

Large diffs are not rendered by default.

22,819 changes: 22,819 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Users.Functions.yml

Large diffs are not rendered by default.

35,638 changes: 35,638 additions & 0 deletions openApiDocs_KiotaCompat/v1.0/Users.yml

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions tools/DownloadOpenApiDocKiotaCompat.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
# Kiota-compatible variant of DownloadOpenApiDoc.ps1.
#
# Instead of the PowerShell conversion profile, this slices the Kiota base
# document (fileName=openapi, which has OpenApiConvertSettings.EnableDiscriminatorValue = true
# and preserves AnyOf/OneOf + discriminators) and applies no PowerShell styling (style=Plain),
# producing per-module OpenAPI docs suitable for Kiota SDK generation.
[CmdletBinding()]
Param(
[string] $ModuleName,
[string] $ModuleRegex,
[string] $OpenApiDocOutput,
[string] $GraphVersion,
[switch] $ForceRefresh,
[int] $RequestCount = 1
)

if (-not (Test-Path $OpenApiDocOutput)) {
New-Item -Path $OpenApiDocOutput -Type Directory
}

$OpenApiBaseUrl = "https://graph-devx-api.microsoft.com"
$OpenApiServiceUrl = ("$OpenApiBaseUrl/`$openapi?tags={0}&title=$ModuleName&openapiversion=3&style=Plain&fileName=openapi&graphVersion=$GraphVersion" -f $ModuleRegex)
if ($ForceRefresh.IsPresent) {
$OpenApiServiceUrl = "$OpenApiServiceUrl&forceRefresh=true"
}
Write-Debug "[$RequestCount] Downloading Kiota-compatible OpenAPI doc for '$ModuleName' module: $OpenApiServiceUrl"
$Retries = 3
$Delay = 3
$Retrycount = 0
$Completed = $false
while (-not $Completed) {
try {
Invoke-WebRequest $OpenApiServiceUrl -OutFile "$OpenApiDocOutput\$ModuleName.yml"
$Completed = $true
}
catch {
$Exception = $_.Exception
switch ($Exception.Response.StatusCode.value__) {
{ @(429, 503, 504) -contains $_ } {
if ($Retrycount -ge $Retries) {
Write-Warning "Request to $OpenApiServiceUrl failed the maximum number of $Retrycount times."
throw
}
else {
[ref]$RetryAfterHeader = $null
if ($Exception.Response.Headers.TryGetValues("Retry-After", $RetryAfterHeader)) {
# Use Retry-After response header
$DelayInSeconds = $RetryAfterHeader.Value
}
else {
# Use exponential backoff
$mPow = [math]::Pow(2, $Retrycount)
$DelayInSeconds = $mPow * $Delay
}

Write-Warning "Request to $OpenApiServiceUrl failed. Retrying in $DelayInSeconds seconds."
Start-Sleep $DelayInSeconds
$Retrycount++
}
}
404 {
Write-Warning "Request to $OpenApiServiceUrl returned 404. Download will be skipped."
$Completed = $true
}
default {
# Get HTTP error message from DevX api, Re-throw error to be handled Upstream
$ErrorMessage = $Exception.Message
Write-Warning "[$RequestCount] Request for $ModuleName failed with error message: $ErrorMessage"
throw
}
}
}
}
73 changes: 73 additions & 0 deletions tools/UpdateOpenApiKiotaCompat.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
# Kiota-compatible variant of UpdateOpenApi.ps1.
#
# Uses the same per-module regex mapping (config\ModulesMapping.jsonc) to slice the
# Kiota base OpenAPI document (fileName=openapi, style=Plain) into per-module docs that
# preserve discriminators/AnyOf/OneOf and are suitable for Kiota SDK generation.
#
# The output is written to a separate folder (default: .\openApiDocs_KiotaCompat) so the
# existing PowerShell OpenAPI flow (.\openApiDocs) remains untouched. The PowerShell-specific
# post-processing (TweakOpenApi.ps1) is intentionally NOT run.
[CmdletBinding()]
Param(
[string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc"),
[string] $OpenApiDocOutput = (Join-Path $PSScriptRoot "..\openApiDocs_KiotaCompat"),
[switch] $BetaGraphVersion,
[switch] $SkipForceRefresh
)

$ErrorActionPreference = 'Stop'
$LASTEXITCODE = $null
if ($PSEdition -ne 'Core') {
Write-Error 'This script requires PowerShell Core to execute.'
}

if (!(Get-Module powershell-yaml -ListAvailable)) {
# Install Powershell-yaml
Install-Module powershell-yaml -Force
}

$GraphVersion = "v1.0"
if ($BetaGraphVersion) {
$GraphVersion = "beta"
}

$OpenApiDocOutput = Join-Path $OpenApiDocOutput $GraphVersion

# Load PS Scripts
$DownloadOpenApiDocPS1 = Join-Path $PSScriptRoot ".\DownloadOpenApiDocKiotaCompat.ps1" -Resolve

if (-not (Test-Path $ModuleMappingConfigPath)) {
Write-Error "Module mapping file not be found: $ModuleMappingConfigPath."
}
$v1Excludes = @("WindowsUpdates")
$betaExcludes = @("DeviceManagement.Administration", "Mail", "ManagedTenants")
$Stopwatch = [system.diagnostics.stopwatch]::StartNew()
[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable
$ModuleMapping.Keys | ForEach-Object -Begin { $RequestCount = 0 } -End { Write-Debug "Requests: $RequestCount" } -Process {
$ModuleName = $_
if (-not ($v1Excludes -contains $ModuleName -and $GraphVersion -eq "v1.0")) {
$ForceRefresh = $false
# Check whether ForceRefresh is required, Only required for the First Request.
if ($RequestCount -eq 0 -and $SkipForceRefresh -eq $false) {
$ForceRefresh = $true
}

try {
# Omit beta version of DeviceManagement.Administration module for further troubleshooting
if (-not($betaExcludes -contains $ModuleName -and $GraphVersion -eq "beta")) {
# Download Kiota-compatible OpenAPI document for module.
& $DownloadOpenApiDocPS1 -ModuleName $ModuleName -ModuleRegex $ModuleMapping[$ModuleName] -OpenApiDocOutput $OpenApiDocOutput -GraphVersion $GraphVersion -ForceRefresh:$ForceRefresh -RequestCount $RequestCount
}
}
catch {
Write-Error $_.Exception
}
$RequestCount++
}
}
$stopwatch.Stop()
Write-Debug "Downloaded $GraphVersion Kiota-compatible OpenAPI files in '$($Stopwatch.Elapsed.TotalMinutes)` minutes."
Write-Host -ForegroundColor Green "-------------Done-------------"
Loading