Skip to content

Commit 46c0d65

Browse files
Microsoft Graph DevX ToolingMicrosoft Graph DevX Tooling
Microsoft Graph DevX Tooling
authored and
Microsoft Graph DevX Tooling
committed
Updated the open Api tweak
1 parent b591ad9 commit 46c0d65

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

tools/TweakOpenApi.ps1

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ $prepositionReplacements = @{
2020
}
2121

2222
$wordReplacements = @{
23-
Deltum = "delta"
24-
Quotum = "quota"
23+
Deltum = "delta"
24+
Quotum = "quota"
2525
Statistic = "statistics"
2626
}
2727
$targetOperationIdRegex = [Regex]::new("([a-z*])($($prepositionReplacements.Keys -join "|"))([A-Z*]|$)", "Compiled")
@@ -33,21 +33,24 @@ Get-ChildItem -Path $OpenAPIFilesPath | ForEach-Object {
3333
$updatedContent = Get-Content $filePath | ForEach-Object {
3434
if ($_.contains("operationId:")) {
3535
$operationId = $_
36-
$wordReplacements.Keys | ForEach-Object {
37-
if ($operationId.EndsWith($_, "CurrentCultureIgnoreCase")) {
38-
$operationId = ($operationId -replace $_, $wordReplacements[$_])
39-
$modified = $true
40-
Write-Debug "$_ -> $operationId".Trim()
36+
#For the OR preposition, we need to check if the operationId contains 'Org' as it is a reserved word.
37+
if (-not($operationId -contains "Org")) {
38+
$wordReplacements.Keys | ForEach-Object {
39+
if ($operationId.EndsWith($_, "CurrentCultureIgnoreCase")) {
40+
$operationId = ($operationId -replace $_, $wordReplacements[$_])
41+
$modified = $true
42+
Write-Debug "$_ -> $operationId".Trim()
43+
}
4144
}
42-
}
4345

44-
if (($targetOperationIdRegex.Match($_)).Success) {
45-
$prepositionReplacements.Keys | ForEach-Object {
46-
# Replace prepositions with replacement word.
47-
#e.g., 'applications_GetCreatedOnBehalfOfByRef' will be renamed to 'applications_GetCreatedOnBehalfGraphOPreGraphBPreRef'.
48-
$operationId = ($operationId -creplace $_, $prepositionReplacements[$_])
49-
$modified = $true
50-
Write-Debug "$_ -> $operationId".Trim()
46+
if (($targetOperationIdRegex.Match($_)).Success) {
47+
$prepositionReplacements.Keys | ForEach-Object {
48+
# Replace prepositions with replacement word.
49+
#e.g., 'applications_GetCreatedOnBehalfOfByRef' will be renamed to 'applications_GetCreatedOnBehalfGraphOPreGraphBPreRef'.
50+
$operationId = ($operationId -creplace $_, $prepositionReplacements[$_])
51+
$modified = $true
52+
Write-Debug "$_ -> $operationId".Trim()
53+
}
5154
}
5255
}
5356
return $operationId

0 commit comments

Comments
 (0)