Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
8 stars 29 forks source link

bug(tcgc): `getSdkHttpParameter()` doesn't handle default value #1030

Closed archerzz closed 2 weeks ago

archerzz commented 3 weeks ago

Describe the bug

We try to set a endpoint parameter with default value in https://github.com/Azure/cadl-ranch/pull/598

@server(
  "{endpoint}",
  "Test server endpoint",
  {
    endpoint: string = "http://localhost:3000",
  }
)

The parameter can be fetched in TCGC, but default value is not parsed. Check the source codes of getSdkHttpParameter(), and it seems not handle default value: https://github.com/Azure/typespec-azure/blob/5c10b3e3524936610283b4044ddd01c73a22827f/packages/typespec-client-generator-core/src/http.ts#L294

Reproduction

Just try to parse the definition above.

Checklist

tadelesh commented 3 weeks ago

@iscai-msft i remembered that only when the default value is happened in server endpoint that we will use it as client default value, is that right? if so, it seems we missed this in current code.

iscai-msft commented 2 weeks ago

Yep, it's only for api version and endpoint. This information is in .templateArguments though, so I don't think this is an issue. Closing. If it's still an issue can you reopen @archerzz