Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
Tracked by #3994
archerzz opened this issue Jun 18, 2024 · 4 comments · Fixed by #1266
Closed
4 tasks done
Tracked by #3994

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

archerzz opened this issue Jun 18, 2024 · 4 comments · Fixed by #1266
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@archerzz
Copy link
Member

Describe the bug

We try to set a endpoint parameter with default value in Azure/cadl-ranch#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:

export function getSdkHttpParameter(

Reproduction

Just try to parse the definition above.

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@tadelesh
Copy link
Member

@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
Copy link
Contributor

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

@archerzz archerzz reopened this Jul 29, 2024
@archerzz
Copy link
Member Author

@iscai-msft for parameters in .templateArguments, looks like I could not get the defaut value unless I parse the __raw.defaultValue. Maybe we should set the .clientDefaultValue?
image

@iscai-msft
Copy link
Contributor

This is a good point, we purposefully don't take defaultValue into account unless for endpoint or api-version related information. I think we should take into account this information since this is endpoint related. I'm going to make a PR and merge it after I make sure people are ok with it. Thanks @archerzz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants