-
Notifications
You must be signed in to change notification settings - Fork 68
[tcgc] add @clientOption decorator
#3827
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
Open
iscai-msft
wants to merge
13
commits into
Azure:main
Choose a base branch
from
iscai-msft:tcgc/clientOptions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3ea0e39
add clientOption decorator
07afed4
add changeset
864f545
Merge branch 'main' of https://github.com/Azure/typespec-azure into t…
e20ce1f
switch to valueof unknown for value
2977dba
add suppression comments
5695753
add client options link
a697725
add doc
7a01d25
add helper method
84f360d
format
cbbac63
add tests for array and dict
c87d570
build
cec0d0a
switch over to Value
38d267c
add tests for namespace and interface
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@azure-tools/typespec-client-generator-core" | ||
| --- | ||
|
|
||
| Add `@clientOption` flag for experimental, language-specific flags |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import { | |
| Scalar, | ||
| Type, | ||
| Union, | ||
| Value, | ||
| createDiagnosticCollector, | ||
| getEffectiveModelType, | ||
| getFriendlyName, | ||
|
|
@@ -41,8 +42,10 @@ import { | |
| listOperationsInOperationGroup, | ||
| } from "./decorators.js"; | ||
| import { | ||
| DecoratorInfo, | ||
| SdkBodyParameter, | ||
| SdkClient, | ||
| SdkClientOption, | ||
| SdkClientType, | ||
| SdkCookieParameter, | ||
| SdkHeaderParameter, | ||
|
|
@@ -897,3 +900,32 @@ export function getNamespaceFromType( | |
| } | ||
| return undefined; | ||
| } | ||
|
|
||
| const CLIENT_OPTION_DECORATOR_NAME = "Azure.ClientGenerator.Core.@clientOption"; | ||
|
|
||
| /** | ||
| * Get all client options from a decorated SDK type. | ||
| * This is a convenience function for extracting `@clientOption` decorator data | ||
| * from the decorators array on SDK types. | ||
| * | ||
| * @param decorators - The decorators array from an SDK type (model, enum, operation, property, etc.) | ||
| * @returns An array of client options with their name, value, and optional scope | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const sdkModel = context.sdkPackage.models.find(m => m.name === "MyModel"); | ||
| * const clientOptions = getClientOptions(sdkModel.decorators); | ||
| * for (const option of clientOptions) { | ||
| * console.log(`Option: ${option.name} = ${option.value}`); | ||
| * } | ||
| * ``` | ||
| */ | ||
| export function getClientOptions(decorators: DecoratorInfo[]): SdkClientOption[] { | ||
| return decorators | ||
| .filter((d) => d.name === CLIENT_OPTION_DECORATOR_NAME) | ||
| .map((d) => ({ | ||
| name: d.arguments.name as string, | ||
| value: d.arguments.value as Value, | ||
| scope: d.arguments.scope as string | undefined, | ||
| })); | ||
| } | ||
|
Comment on lines
+923
to
+931
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.