Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-client-java"
---

Fix duplicate method in generated samples, when advanced-versioning=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: dependencies
packages:
- "@typespec/http-client-java"
---

Update Node.js dependencies: @azure-tools/typespec-autorest 0.69.1, @azure-tools/typespec-azure-resource-manager 0.69.1, @azure-tools/typespec-azure-rulesets 0.69.1, @microsoft/api-extractor 7.58.9, @types/node 25.9.3, @vitest/coverage-v8 4.1.9, @vitest/ui 4.1.9, vitest 4.1.9
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"@typespec/streams": "0.83.0",
"@azure-tools/typespec-azure-core": "0.69.0",
"@azure-tools/typespec-client-generator-core": "0.69.0",
"@azure-tools/typespec-azure-resource-manager": "0.69.0",
"@azure-tools/typespec-autorest": "0.69.0"
"@azure-tools/typespec-azure-resource-manager": "0.69.1",
"@azure-tools/typespec-autorest": "0.69.1"
},
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.microsoft.typespec.http.client.generator.mgmt.model.clientmodel.examplemodel.ParameterExample;
import io.clientcore.core.utils.CoreUtils;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -47,7 +48,16 @@ public final void write(com.microsoft.typespec.http.client.generator.mgmt.model.
javaFile.javadocComment(commentBlock -> commentBlock
.description(String.format("Samples for %1$s %2$s", example.getGroupName(), example.getMethodName())));
javaFile.publicFinalClass(className, classBlock -> {
Set<String> methodSignatureWritten = new HashSet<>();
for (ExampleMethod exampleMethod : exampleMethods) {
String methodSignature = exampleMethod.getMethodSignature();
if (methodSignatureWritten.contains(methodSignature)) {
// skip this method, as it duplicate with method already written to the class
// this usually happen on "advanced-versioning: true", where we have overload on the SDK method
continue;
}
methodSignatureWritten.add(methodSignature);

if (!CoreUtils.isNullOrEmpty(exampleMethod.getExample().getOriginalFileName())) {
classBlock.blockComment(getExampleTag(exampleMethod.getExample()));
}
Expand All @@ -57,7 +67,6 @@ public final void write(com.microsoft.typespec.http.client.generator.mgmt.model.
commentBlock.param(exampleMethod.getExample().getEntryName(),
exampleMethod.getExample().getEntryDescription());
});
String methodSignature = exampleMethod.getMethodSignature();
if (exampleMethod.getHelperFeatures().contains(ExampleHelperFeature.ThrowsIOException)) {
methodSignature += " throws IOException";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"@typespec/streams": "0.83.0",
"@azure-tools/typespec-azure-core": "0.69.0",
"@azure-tools/typespec-client-generator-core": "0.69.0",
"@azure-tools/typespec-azure-resource-manager": "0.69.0",
"@azure-tools/typespec-autorest": "0.69.0"
"@azure-tools/typespec-azure-resource-manager": "0.69.1",
"@azure-tools/typespec-autorest": "0.69.1"
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package tsptest.armversioned.generated;

/**
* Samples for TopLevelArmResources GetByResourceGroup.
*/
public final class TopLevelArmResourcesGetByResourceGroupSamples {
/*
* x-ms-original-file: 2024-12-01/TopLevelArmResources_Get.json
*/
/**
* Sample code: TopLevelArmResources Get.
*
* @param manager Entry point to ArmVersionedManager.
*/
public static void topLevelArmResourcesGet(tsptest.armversioned.ArmVersionedManager manager) {
manager.topLevelArmResources()
.getByResourceGroupWithResponse("resource-group-name", "resource-name", "parameter-value",
"new-parameter-value", com.azure.core.util.Context.NONE);
}
}
Comment thread
weidongxu-microsoft marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"operationId": "TopLevelArmResources_Get",
"title": "TopLevelArmResources Get",
"parameters": {
"resourceGroupName": "resource-group-name",
"topLevelArmResourcePropertiesName": "resource-name",
"api-version": "2024-12-01",
"parameter": "parameter-value",
"newParameter": "new-parameter-value"
},
"responses": {
"200": {
"body": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group-name/providers/TspTest.ArmVersioned/topLevelArmResources/resource-name",
"name": "resource-name",
"type": "TspTest.ArmVersioned/topLevelArmResources",
"location": "eastus",
"properties": {
"provisioningState": "Succeeded"
}
}
}
}
}
Loading
Loading