Azure / azure-sdk-for-cpp

This repository is for active development of the Azure SDK for C++. For consumers of the SDK we recommend visiting our versioned developer docs at https://azure.github.io/azure-sdk-for-cpp.
MIT License
181 stars 126 forks source link

apiVersion param needs to be moved away from the method definition to use the param on the client. #6072

Closed gearama closed 1 month ago

gearama commented 1 month ago

The code generated from typespec has an extra param attached to the APIs that is not in the current code: Generated code : Azure::Response FullBackupStatus( std::string const& apiVersion, std::string const& jobId, Azure::Core::Context const& context = {});

Current code :

Response<Models::BackupOperationStatus> FullBackupStatus(
    std::string const& jobId,
    Core::Context const& context = {});

in the current code the client wide version param is used url.SetQueryParameters({{"api-version", m_apiVersion}}); <-- this is a memeber of the client class set as part of the constructor

as opposed to the generated code :

url.AppendQueryParameter("api-version", Azure::Core::Url::Encode(apiVersion));

ahsonkhan commented 1 month ago

The same issue occurs in appconfig generation.

We expect the apiVersion to be elevated into a client-level param/options, and not a member/operation-level param.

Current:

  Azure::Response<CheckKeysResult> CheckKeys(
      std::string const& apiVersion,
      CheckKeysOptions const& options = {},
      Azure::Core::Context const& context = {});

Expected:

  Azure::Response<CheckKeysResult> CheckKeys(
      CheckKeysOptions const& options = {},
      Azure::Core::Context const& context = {});
antkmsft commented 1 month ago

Fixed in https://github.com/Azure/autorest.cpp/pull/405