@@ -20,8 +20,8 @@ $prepositionReplacements = @{
20
20
}
21
21
22
22
$wordReplacements = @ {
23
- Deltum = " delta"
24
- Quotum = " quota"
23
+ Deltum = " delta"
24
+ Quotum = " quota"
25
25
Statistic = " statistics"
26
26
}
27
27
$targetOperationIdRegex = [Regex ]::new(" ([a-z*])($ ( $prepositionReplacements.Keys -join " |" ) )([A-Z*]|$)" , " Compiled" )
@@ -33,21 +33,24 @@ Get-ChildItem -Path $OpenAPIFilesPath | ForEach-Object {
33
33
$updatedContent = Get-Content $filePath | ForEach-Object {
34
34
if ($_.contains (" operationId:" )) {
35
35
$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
+ }
41
44
}
42
- }
43
45
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
+ }
51
54
}
52
55
}
53
56
return $operationId
0 commit comments