From b62b859d40a91ab4b0b7a11bc0fc0beec06e88f8 Mon Sep 17 00:00:00 2001 From: RodgeFu Date: Fri, 15 Mar 2024 14:02:45 +0800 Subject: [PATCH] make the script backward compat --- .../extensions/openapi-to-typespec/convert.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/extensions/openapi-to-typespec/convert.ps1 b/packages/extensions/openapi-to-typespec/convert.ps1 index f3e706f226..12df24f81d 100644 --- a/packages/extensions/openapi-to-typespec/convert.ps1 +++ b/packages/extensions/openapi-to-typespec/convert.ps1 @@ -14,10 +14,6 @@ param( [string] # Specifies the swagger config file, not the swagger json, but the readme config. $swaggerConfigFile, - [Parameter(Mandatory)] - [string] - # Specifies the corresponding autorest.md file in azure-sdk-for-net repo used by autorest.csharp codegen. - $csharpAutorestFile, [string] # Specified the output folder, deafult to current folder. $outputFolder, @@ -26,12 +22,18 @@ param( $csharpCodegen = "https://aka.ms/azsdk/openapi-to-typespec-csharp", [string] # Specified the converter codegen, default to https://aka.ms/azsdk/openapi-to-typespec. - $converterCodegen = "." -) + $converterCodegen = ".", + [string] + # Specifies the corresponding autorest.md file in the azure-sdk-for-net repo so that the convert will load it instead of the swagger config file when generating metadata which would include more csharp configurations (i.e. rename rules) + $csharpAutorestFile = "") function GenerateMetadata () { Write-Host "##Generating metadata with csharp codegen in $outputFolder with $csharpCodegen" + if($csharpAutorestFile -eq "") + { + $csharpAutorestFile = $swaggerConfigFile + } $cmd = "autorest --version=3.10.1 --csharp --isAzureSpec --isArm --max-memory-size=8192 --use=`"$csharpCodegen`" --output-folder=$outputFolder --mgmt-debug.only-generate-metadata --azure-arm --skip-csproj $csharpAutorestFile" Write-Host "$cmd" Invoke-Expression $cmd