question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated createClient method does not use all parameters for parameterized host

See original GitHub issue

When using a parameterized host with multiple parts, the TS autorest client will only include parameters in the createClient method for one of the parts.

This impacts the PR and linked spec here.

Our parameterized host looks like the following:

“{tenantId}-{resourceName}.{dnsSuffix}”.

The expected createClient method would looks like the following:

export default function createClient(
  tenantId: string,
  devCenter: string,
  credentials: TokenCredential,
  devCenterDnsSuffix: string = "devcenter.azure.com",
  options: ClientOptions = {}
): AzureDevCenterClient {
  const baseUrl = options.baseUrl ?? `https://${tenantId}-${devCenter}.${devCenterDnsSuffix}`;

The actual method is as follows:

export default function createClient(
  tenantId: string,
  credentials: TokenCredential,
  options: ClientOptions = {}
): AzureDevCenterClient {
  const baseUrl = options.baseUrl ?? `https://${tenantId}-{devCenter}.{devCenterDnsSuffix}`;

autorest.typescript version is 6.0.0-rc.1

This generates an unusable createClient method, blocking use of the package. Happy to help investigate or provide more info as needed!

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
chrissmillercommented, Oct 25, 2022

@MaryGao rc.2 fixes this issue for us, thank you so much! We are noticing a second issue withe the parameterized host in createClient though – we have a default value for one of the host parameters, and the default value is not provided. We have manually fixed this for our PR, let me know if there is a fix we can consume instead though!

So rather than the expected output, we get:

export interface AzureDevCenterClientOption extends ClientOptions {
   devCenterDnsSuffix: string;
}

export default function createClient(
  tenantId: string,
  devCenter: string,
  credentials: TokenCredential,
  options: ClientOptions = {}
): AzureDevCenterClient { 
  // Handle the default value here
}

Link to the spec doc: https://github.com/Azure/azure-rest-api-specs/blob/75a8d8dcc9f6d0ec626bdeb32f5154f20c8c61cd/specification/devcenter/data-plane/Microsoft.DevCenter/preview/2022-03-01-preview/devcenter.json

0reactions
MaryGaocommented, Nov 30, 2022

Close this issue considering the issue resolved. Feel free to reopen it if necessary!

Read more comments on GitHub >

github_iconTop Results From Across the Web

RedisClientType hard to use with createClient #1865
The RedisClientType has two generic parameters that make it hard to use to signify the return type of createClient .
Read more >
Make HTTP requests using IHttpClientFactory in ASP.NET ...
A new instance of HttpClient is created. The configuration action is called. To create a named client, pass its name into CreateClient :...
Read more >
How Setup Parameters for AddHttpClient when ...
I'm try setting up a IHttpClientFactory , and i'd like to know how to send it parameters when it is created, those parameters...
Read more >
RequestsLibrary - MarketSquare
The quickest way to start is using the requests keywords and urls see below examples: ... If the response body does not contain...
Read more >
Content Delivery API
Contentful defines the sys.id property for every resource that is not a ... You can use the order parameter when paging through larger...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found