Azure / autorest.python

Extension for AutoRest (https://github.com/Azure/autorest) that generates Python code
MIT License
79 stars 57 forks source link

python emitter always pad specific enum name (e.g. int) #2639

Closed msyyc closed 3 months ago

msyyc commented 3 months ago

The follow typespec:

import "@typespec/http";
import "@azure-tools/cadl-ranch-expect";

using TypeSpec.Http;

@scenarioService("/authentication/api-key")
@doc("Illustrates clients generated with ApiKey authentication.")
@useAuth(ApiKeyAuth<ApiKeyLocation.header, "x-ms-api-key">)
namespace Authentication.ApiKey;

enum MyEnum {
  Enum: "Enum",
  Int: "Int",
}
model MyModel {
    type: MyEnum;
    int: int64;
}

@scenario
@scenarioDoc("Expects header 'x-ms-api-key': 'valid-key'")
@doc("Check whether client is authenticated")
@get
@route("/valid")
op valid(@body body: MyModel): NoContentResponse;

python emitter generates enum with padded enum name INT_ENUM which is expected to INIT

image