Skip to content

Commit

Permalink
Merge branch 'main' into specs_arm_location_base_resource
Browse files Browse the repository at this point in the history
  • Loading branch information
v-hongli1 authored Jan 9, 2025
2 parents 9ec50e4 + fe47f65 commit 6e1cd1f
Show file tree
Hide file tree
Showing 41 changed files with 2,122 additions and 236 deletions.
8 changes: 8 additions & 0 deletions .chronus/changes/rust-client-names-2025-0-6-15-6-10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@azure-tools/azure-http-specs"
---

Add Rust to client naming scenarios
7 changes: 7 additions & 0 deletions .chronus/changes/scope-decorator-2024-11-18-12-59-12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-client-generator-core"
---

Add `@scope` decorator to define the language scope for operation
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-client-generator-core"
---

add `@alternateType` decorator
8 changes: 8 additions & 0 deletions .github/policies/issues.triage.generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ configuration:
label: eng
- hasLabel:
label: ide
- hasLabel:
label: cli/psh
then:
- addLabel:
label: needs-area
Expand All @@ -51,6 +53,8 @@ configuration:
label: eng
- labelAdded:
label: ide
- labelAdded:
label: cli/psh
then:
- removeLabel:
label: needs-area
Expand All @@ -74,6 +78,8 @@ configuration:
label: eng
- labelRemoved:
label: ide
- labelRemoved:
label: cli/psh
- not:
or:
- hasLabel:
Expand All @@ -88,6 +94,8 @@ configuration:
label: eng
- hasLabel:
label: ide
- hasLabel:
label: cli/psh
then:
- addLabel:
label: needs-area
6 changes: 6 additions & 0 deletions .github/policies/prs.triage.generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ configuration:
then:
- addLabel:
label: ide
- if:
- includesModifiedFiles:
files: []
then:
- addLabel:
label: cli/psh
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ Area of the codebase
| `emitter:autorest` | #957300 | Issues for @azure-tools/typespec-autorest emitter |
| `eng` | #65bfff | |
| `ide` | #846da1 | Issues for Azure specific ide features |
| `cli/psh` | #9EB120 | Issues for Azure CLI/PSH features |

#### issue_kinds

Expand Down
2 changes: 2 additions & 0 deletions packages/azure-http-specs/specs/client/naming/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Property {
@clientName("JavaName", "java")
@clientName("TSName", "javascript")
@clientName("python_name", "python")
@clientName("rustName", "rust")
defaultName: boolean;
}

Expand Down Expand Up @@ -150,6 +151,7 @@ namespace Model {
@clientName("JavaModel", "java")
@clientName("TSModel", "javascript")
@clientName("PythonModel", "python")
@clientName("rustName", "rust")
model ModelWithLanguageClientName {
@doc("Pass in true")
defaultName: boolean;
Expand Down
18 changes: 18 additions & 0 deletions packages/typespec-client-generator-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Change Log - @azure-tools/typespec-client-generator-core

## 0.49.1

### Bug Fixes

- [#2000](https://github.com/Azure/typespec-azure/pull/2000) ensure operation examples to be ordered
- [#2004](https://github.com/Azure/typespec-azure/pull/2004) get correct pageable info for azure pageable operation with inheritance return model
- [#2034](https://github.com/Azure/typespec-azure/pull/2034) refine cross language definition id logic

### Features

- [#2010](https://github.com/Azure/typespec-azure/pull/2010) add `getHttpOperationParameter` helper function
- [#1978](https://github.com/Azure/typespec-azure/pull/1978) Add `@apiVersion` decorator to override whether a parameter is an api version or not

### Breaking Changes

- [#2007](https://github.com/Azure/typespec-azure/pull/2007) fix typo of `crossLanguageDefinitionId` of method.


## 0.49.0

### Bug Fixes
Expand Down
205 changes: 152 additions & 53 deletions packages/typespec-client-generator-core/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
ModelProperty,
Namespace,
Operation,
Scalar,
Type,
Union,
} from "@typespec/compiler";
Expand All @@ -15,7 +16,7 @@ import type {
* Changes the name of a method, parameter, property, or model generated in the client SDK
*
* @param rename The rename you want applied to the object
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
Expand All @@ -42,7 +43,7 @@ export type ClientNameDecorator = (
* Whether you want to generate an operation as a convenient operation.
*
* @param value Whether to generate the operation as convenience method or not.
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
Expand All @@ -61,7 +62,7 @@ export type ConvenientAPIDecorator = (
* Whether you want to generate an operation as a protocol operation.
*
* @param value Whether to generate the operation as protocol or not.
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
Expand All @@ -80,7 +81,7 @@ export type ProtocolAPIDecorator = (
* Create a ClientGenerator.Core client out of a namespace or interface
*
* @param value Optional configuration for the service.
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example Basic client setting
* ```typespec
Expand Down Expand Up @@ -113,7 +114,7 @@ export type ClientDecorator = (
/**
* Create a ClientGenerator.Core operation group out of a namespace or interface
*
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
Expand Down Expand Up @@ -145,7 +146,7 @@ export type OperationGroupDecorator = (
* otherwise a warning will be added to diagnostics list.
*
* @param value The usage info you want to set for this model.
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example Expand usage for model
* ```typespec
Expand Down Expand Up @@ -217,7 +218,7 @@ export type UsageDecorator = (
* otherwise a warning will be added to diagnostics list.
*
* @param value The access info you want to set for this model or operation.
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example Set access
* ```typespec
Expand Down Expand Up @@ -353,7 +354,7 @@ export type AccessDecorator = (
/**
* Set whether a model property should be flattened or not.
*
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
Expand All @@ -376,7 +377,7 @@ export type FlattenPropertyDecorator = (
*
* @param original : The original service definition
* @param override : The override method definition that specifies the exact client method you want
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
Expand Down Expand Up @@ -427,7 +428,7 @@ export type OverrideDecorator = (
/**
* Whether a model needs the custom JSON converter, this is only used for backward compatibility for csharp.
*
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
Expand All @@ -446,7 +447,7 @@ export type UseSystemTextJsonConverterDecorator = (
/**
* Client parameters you would like to add to the client. By default, we apply endpoint, credential, and api-version parameters. If you add clientInitialization, we will append those to the default list of parameters.
*
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
Expand Down Expand Up @@ -477,7 +478,7 @@ export type ClientInitializationDecorator = (
/**
* Alias the name of a client parameter to a different name. This permits you to have a different name for the parameter in client initialization then on individual methods and still refer to the same parameter.
*
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
Expand Down Expand Up @@ -511,18 +512,19 @@ export type ParamAliasDecorator = (
* By default, the client namespace for them will follow the TypeSpec namespace.
*
* @param rename The rename you want applied to the object
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
* @clientNamespace("ContosoClient")
* namespace Contoso;
* ```
* @example
* ```typespec
* @clientName("ContosoJava", "java")
* @clientName("ContosoPython", "python")
* @clientName("ContosoCSharp", "csharp")
* @clientName("ContosoJavascript", "javascript")
* @clientNamespace("ContosoJava", "java")
* @clientNamespace("ContosoPython", "python")
* @clientNamespace("ContosoCSharp", "csharp")
* @clientNamespace("ContosoJavascript", "javascript")
* namespace Contoso;
* ```
*/
Expand All @@ -533,6 +535,76 @@ export type ClientNamespaceDecorator = (
scope?: string,
) => void;

/**
* Set an alternate type for a model property, scalar, or function parameter. Note that `@encode` will be overridden by the one defined in alternate type.
*
* @param source The source type you want to apply the alternate type to. Only scalar types are supported.
* @param alternate The alternate type you want applied to the target. Only scalar types are supported.
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
* model Foo {
* date: utcDateTime;
* }
* @@alternateType(Foo.date, string);
* ```
* @example
* ```typespec
* scalar storageDateTime extends utcDataTime;
* @@alternateType(storageDateTime, string, "python");
* ```
* @example
* ```typespec
* op test(@param @alternateType(string) date: utcDateTime): void;
* ```
*/
export type AlternateTypeDecorator = (
context: DecoratorContext,
source: ModelProperty | Scalar,
alternate: Scalar,
scope?: string,
) => void;

/**
* To define the client scope of an operation.
*
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
* @scope("!csharp")
* op test: void;
* ```
*/
export type ScopeDecorator = (context: DecoratorContext, target: Operation, scope?: string) => void;

/**
* Use to override default assumptions on whether a parameter is an api-version parameter or not.
* By default, we do matches with the `api-version` or `apiversion` string in the parameter name. Since api versions are
* a client parameter, we will also elevate this parameter up onto the client.
*
* @param value If true, we will treat this parameter as an api-version parameter. If false, we will not. Default is true.
* @param scope The language scope you want this decorator to apply to. If not specified, will apply to all language emitters.
* You can use "!" to specify negation such as "!(java, python)" or "!java, !python".
* @example
* ```typespec
* namespace Contoso;
*
* op test(
* @apiVersion
* @header("x-ms-version")
* version: string
* ): void;
* ```
*/
export type ApiVersionDecorator = (
context: DecoratorContext,
target: ModelProperty,
value?: boolean,
scope?: string,
) => void;

export type AzureClientGeneratorCoreDecorators = {
clientName: ClientNameDecorator;
convenientAPI: ConvenientAPIDecorator;
Expand All @@ -547,4 +619,7 @@ export type AzureClientGeneratorCoreDecorators = {
clientInitialization: ClientInitializationDecorator;
paramAlias: ParamAliasDecorator;
clientNamespace: ClientNamespaceDecorator;
alternateType: AlternateTypeDecorator;
scope: ScopeDecorator;
apiVersion: ApiVersionDecorator;
};
Loading

0 comments on commit 6e1cd1f

Please sign in to comment.