Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit c050b4c

Browse files
authored
Resolve UnableToExtractDetailsFromSdkAssembly error when OperationType in OperationId conflicts with Definition name. (#332)
When OperationType value conflicts with a definition name, AutoREST generates method name by adding Method to the OperationType. Current error for swagger specs of Azure Servicebus and Relay services. ```powershell Generating module for 'C:\temp\AzureSwaggerSpecs\SwaggerSpecs\servicebus\servicebus.json'. Update-PathFunctionDetails : Module generation failed. If no error messages follow, check the output of code metadata extraction above Unable to find expected method 'CheckNameAvailabilityWithHttpMessagesAsync' on type 'Microsoft.PowerShell.Azservicebus.v001.INamespacesOperations' At C:\Code\PSSwagger\PSSwagger\PSSwagger.psm1:555 char:28 + ... onDetails = Update-PathFunctionDetails -PathFunctionDetails $PathFunc ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : UnableToExtractDetailsFromSdkAssembly,Update-PathFunctionDetails ``` ```powershell Generating module for 'C:\temp\AzureSwaggerSpecs\SwaggerSpecs\relay\relay.json'. Update-PathFunctionDetails : Module generation failed. If no error messages follow, check the output of code metadata extraction above Unable to find expected method 'CheckNameAvailabilityWithHttpMessagesAsync' on type 'Microsoft.PowerShell.Azrelay.v001.INamespacesOperations' At C:\Code\PSSwagger\PSSwagger\PSSwagger.psm1:555 char:28 + ... onDetails = Update-PathFunctionDetails -PathFunctionDetails $PathFunc ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : UnableToExtractDetailsFromSdkAssembly,Update-PathFunctionDetails ```
1 parent d7a5528 commit c050b4c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

PSSwagger/Paths.psm1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,12 +1034,13 @@ function Set-ExtendedCodeMetadata {
10341034
}
10351035

10361036
$operationId = $parameterSetDetail.OperationId
1037-
$methodName = ''
1037+
$methodNames = @()
10381038
$operations = ''
10391039
$operationsWithSuffix = ''
10401040
$opIdValues = $operationId -split '_',2
10411041
if(-not $opIdValues -or ($opIdValues.count -ne 2)) {
1042-
$methodName = $operationId + 'WithHttpMessagesAsync'
1042+
$methodNames += $operationId + 'WithHttpMessagesAsync'
1043+
$methodNames += $operationId + 'Method' + 'WithHttpMessagesAsync'
10431044
} else {
10441045
$operationName = $opIdValues[0]
10451046
$operationType = $opIdValues[1]
@@ -1049,10 +1050,11 @@ function Set-ExtendedCodeMetadata {
10491050
$operationsWithSuffix = $operations + 'Operations'
10501051
}
10511052

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

1055-
$parameterSetDetail['MethodName'] = $methodName
10561058
$parameterSetDetail['Operations'] = $operations
10571059

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

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

11301133
# Process output type
11311134
$returnType = $methodInfo.ReturnType

0 commit comments

Comments
 (0)