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

[tcgc] Add a decorator to signal non-standard service api version patterns #1706

Open
4 tasks done
catalinaperalta opened this issue Oct 17, 2024 · 2 comments · May be fixed by #1978
Open
4 tasks done

[tcgc] Add a decorator to signal non-standard service api version patterns #1706

catalinaperalta opened this issue Oct 17, 2024 · 2 comments · May be fixed by #1978
Assignees
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@catalinaperalta
Copy link
Member

catalinaperalta commented Oct 17, 2024

Clear and concise description of the problem

For brownfield services with non-standard api version patterns we need a way to signal that the parameter or header is specifying the api version for the service in the generated code. We typically default api version parameters to the latest version in generated code, I would like a tcgc decorator that will signal when client libraries should treat a parameter or header like this.

For example, the storage blob service specifies and x-ms-version header on all requests for api versions.

/** Specifies the version of the operation to use for this request. */
  @apiVersion
  @header("x-ms-version")
  version: string,

cc @iscai-msft

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For feature request in the typespec language or core libraries file it in the TypeSpec repo
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@catalinaperalta catalinaperalta added lib:tcgc Issues for @azure-tools/typespec-client-generator-core library and removed needs-area labels Oct 17, 2024
@iscai-msft iscai-msft self-assigned this Oct 18, 2024
@iscai-msft
Copy link
Contributor

I agree, and other design thoughts:

  1. We should lint against people applying the same decorator to multiple different kinds of api version parameters in a single spec
  2. I think @apiVersion(boolean) is a good name for the decorator
  3. To maintain backcompat and sensible default behavior, parameters with name api-version have the @apiVersion decorator applied by default. If you want a parameter called api-version that isn't an @apiVersion parameter, you have to add @apiVersion(false) api-version: string

@catalinaperalta
Copy link
Member Author

@iscai-msft do we have any plans to implement this soon? Storage will need this to allow emitters to generate api version handling correctly.

@iscai-msft iscai-msft linked a pull request Dec 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants