AutoRest 将客户端 ctor 生成为内部 + 忽略凭据标志

AutoRest generates the client ctor as internal + ignores the credentials flag

我正在通过 AutoRest (OpenAPI v3) 生成 C# REST 服务客户端。 我通过 运行 以下命令生成客户端:

autorest --input-file="./Resources/swagger.json" --output-folder="./SomeService/Generated" --namespace="SomeService.Client" --override-client-name="SomeServiceClient" --skip-csproj --public-clients=true --add-credential --csharp

我生成的客户端似乎有两个问题:

  1. ctor 是作为内部生成的,即使我指定客户端应该是 public:
internal SomeServiceClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null)
{
    RestClient = new SomeServiceRestClient(clientDiagnostics, pipeline, endpoint);
    _clientDiagnostics = clientDiagnostics;
    _pipeline = pipeline;
}
  1. 生成的客户端 ctor 不接受凭据,即使我指定了 --add-credential 标志,这是为什么?

我遵循了 https://github.com/Azure/autorest 中提到的说明。 我做错了什么?

  1. 查看 AutoRest 源代码,如果 OpenAPI 规范中的安全架构设置为 AzureKey 或 AADtoken,它只会创建 public 构造函数。这在他们的文档中得到验证 AutoRest source code
    AutoRest Security Schemes documentation

  2. AutoRest 标志的 table 表示 --add-credential 对 .NET 客户端没有任何作用(左起第 4 列)。
    https://github.com/Azure/autorest/blob/main/docs/generate/flags.md#shared-flags

AutoRest v3 似乎仅适用于托管在 Azure 本身的 APIs。有了上面的证据,以及生成客户端的构造函数所需的参数,如 ClientDiagnostics,被声明为 internal,我想我们将不得不找到另一个 API客户端生成器。