Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.
Merged
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
15 changes: 9 additions & 6 deletions PSSwagger/Paths.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1034,12 +1034,13 @@ function Set-ExtendedCodeMetadata {
}

$operationId = $parameterSetDetail.OperationId
$methodName = ''
$methodNames = @()
$operations = ''
$operationsWithSuffix = ''
$opIdValues = $operationId -split '_',2
if(-not $opIdValues -or ($opIdValues.count -ne 2)) {
$methodName = $operationId + 'WithHttpMessagesAsync'
$methodNames += $operationId + 'WithHttpMessagesAsync'
$methodNames += $operationId + 'Method' + 'WithHttpMessagesAsync'
} else {
$operationName = $opIdValues[0]
$operationType = $opIdValues[1]
Expand All @@ -1049,10 +1050,11 @@ function Set-ExtendedCodeMetadata {
$operationsWithSuffix = $operations + 'Operations'
}

$methodName = $operationType + 'WithHttpMessagesAsync'
$methodNames += $operationType + 'WithHttpMessagesAsync'
# When OperationType value conflicts with a definition name, AutoREST generates method name by adding Method to the OperationType.
$methodNames += $operationType + 'Method' + 'WithHttpMessagesAsync'
}

$parameterSetDetail['MethodName'] = $methodName
$parameterSetDetail['Operations'] = $operations

# For some reason, moving this out of this loop causes issues
Expand Down Expand Up @@ -1119,13 +1121,14 @@ function Set-ExtendedCodeMetadata {
$clientType = $propertyObject.PropertyType
}

$methodInfo = $clientType.GetMethods() | Where-Object { $_.Name -eq $MethodName } | Select-Object -First 1
$methodInfo = $clientType.GetMethods() | Where-Object {$MethodNames -contains $_.Name} | Select-Object -First 1
if (-not $methodInfo) {
$resultRecord.ErrorMessages += $LocalizedData.ExpectedMethodOnTypeNotFound -f ($MethodName, $clientType)
$resultRecord.ErrorMessages += $LocalizedData.ExpectedMethodOnTypeNotFound -f (($MethodNames -join ', or '), $clientType)
Export-CliXml -InputObject $resultRecord -Path $CliXmlTmpPath
$errorOccurred = $true
return
}
$parameterSetDetail['MethodName'] = $methodInfo.Name

# Process output type
$returnType = $methodInfo.ReturnType
Expand Down