autorest.typescript icon indicating copy to clipboard operation
autorest.typescript copied to clipboard

The autorest option `azureArm` will return true if no azure-arm or openapi-type defined

Open MaryGao opened this issue 2 years ago • 4 comments

Bug

The autorest option azureArm extracting from method getIsAzureArm in autorestOptions.ts will return true if no azure-arm or openapi-type defined with below code snippet:

async function getIsAzureArm(host: AutorestExtensionHost): Promise<boolean> {
  const flag = (await host.getValue("azure-arm")) === true;
  const openapi = (await host.getValue("openapi-type")) === "arm";

  return flag || openapi;
}

Expected Behavior

The calling await host.getValue("azure-arm") should not be true if no azure-arm provided as input.

MaryGao avatar Apr 13 '22 01:04 MaryGao

Following on this: @joheredi and I faced this issue to while regenerating keyvault-certificates a couple of days ago. We debugged the generator and found that if the openapi-type flag is not present in the config file, the default value would be "arm".

Specifying openapi-type = "data-plane" fixes this behavior. Changing azure-arm to false didn't change the openapi type default value.

This default value seems to be coming from the Modeler 4.

JonathanCrd avatar Apr 20 '22 00:04 JonathanCrd

@timotheeguerin do you recall if M4 has "arm" as default value for openapi-type?

joheredi avatar Apr 20 '22 00:04 joheredi

Autorest core has openapi-type set to arm by default. Not really sure why those 2 flags exist really but not sure what we can change without breaking all uses now.

timotheeguerin avatar Apr 20 '22 14:04 timotheeguerin

Thanks, @timotheeguerin. @sarangan12 I see that checking openapi-type was introduced in this change. Do you recall why azure-arm was not sufficient and we need to check openapi-type

joheredi avatar Apr 20 '22 20:04 joheredi