Azure / autorest.java

Extension for AutoRest (https://github.com/Azure/autorest) that generates Java code
MIT License
32 stars 80 forks source link

tsp, generate origin (JSON) example file name in mgmt sample files #2789

Closed weidongxu-microsoft closed 1 month ago

weidongxu-microsoft commented 1 month ago

fix https://github.com/Azure/autorest.java/issues/2788

code for x-ms-original-file https://github.com/Azure/autorest.java/pull/2789/commits/f6dd96b7a35cac35cdca69e5a68ce3956542840d code for convert that to the relative path in sample file https://github.com/Azure/autorest.java/pull/2789/commits/979314768a9718465d26b9ad3896a3e4bc942a3e

UT with some refactor https://github.com/Azure/autorest.java/pull/2789/commits/5db62b916bf13ebbfe16a09c6b9bb914ac8da02e

test

  * Samples for StandbyVirtualMachinePools Update.
  */
 public final class StandbyVirtualMachinePoolsUpdateSamples {
+    /*
+     * x-ms-original-file:
+     * specification/standbypool/StandbyPool.Management/examples/2023-12-01-preview/
+     * StandbyVirtualMachinePools_Update.json
+     */
     /**
      * Sample code: StandbyVirtualMachinePools_Update.
      *
weidongxu-microsoft commented 1 month ago

The reason of the error in https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3823237&view=logs&j=ca395085-040a-526b-2ce8-bdc85f692774&t=0750e130-1e9a-5b8a-35b2-9986f25ac898 is that now even ClassType class needs JavaSettings, which must be mocked before test.

Hence added BeforeAllTestsExtension for javagen and fluentgen module test https://github.com/Azure/autorest.java/pull/2789/commits/5bcb150cffd9c7a1c4045cfae7315a403d4c673f to init the mocked Javagen/FluentGen

XiaofeiCao commented 1 month ago

Wonder why there's no change in generated samples..

Ah, we don't have samples for arm.tsp....

weidongxu-microsoft commented 1 month ago

Wonder why there's no change in generated samples.

I think we only do this for fluent (no collection for DPG). Your arm.tsp probably not having example file?

XiaofeiCao commented 1 month ago

I think we only do this for fluent. Your arm.tsp probably not having example file?

Yeah, let me add them later.