Azure / autorest.java

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

Implement TCGC's SdkPackage types #2665

Open iscai-msft opened 3 months ago

iscai-msft commented 3 months ago

Language emitters should work to move entirely to TCGC's new ecosystem. The entry point for the ecosystem is accessing .sdkPackage on the SdkContext returned from tcgc

https://azure.github.io/typespec-azure/docs/howtos/DataPlane%20Generation%20-%20DPG/07tcgcTypes

### Tasks
- [x] Replace logics for process operation parameters
- [x] Replace logics for server parameters
- [x] Replace logics for process operation
- [x] Replace logics for process clients
- [x] Replace logics for process response
- [x] Replace logics for process LRO
- [x] Replace logics for process body parameters
- [x] Replace logics for process examples
- [ ] Replace logics for process auth
- [ ] Replace logics for the util functions, e.g. addAcceptedHeader, processEtagHeader etc.
- [ ] Replace logics for versioning
- [ ] Integrate with access and usage
- [ ] Pass cadl-ranch and typespec-tests

TCGC dependencies:

### TCGC dependency issues
- [ ] https://github.com/Azure/typespec-azure/issues/954
- [ ] https://github.com/Azure/typespec-azure/issues/917
- [ ] https://github.com/Azure/typespec-azure/issues/916
- [ ] https://github.com/Azure/typespec-azure/issues/963
- [ ] https://github.com/Azure/typespec-azure/issues/965
- [ ] https://github.com/Azure/typespec-azure/issues/980
- [ ] https://github.com/Azure/typespec-azure/issues/217
- [ ] https://github.com/Azure/typespec-azure/issues/1088
- [ ] https://github.com/Azure/typespec-azure/issues/1060
haolingdong-msft commented 1 month ago

Hi @iscai-msft @lmazuel, Java may need to start this work at June as we are working on below remaining items related with TCGC model types in May. Please let me know if there is any concern. Thank you.

https://github.com/Azure/autorest.java/issues/2728 (tried from emitter side, now depends on TCGC to remove undefined value) https://github.com/Azure/autorest.java/issues/2729 (tried from emitter side, depends on two TCGC issues) https://github.com/Azure/autorest.java/issues/2732 (done) https://github.com/Azure/autorest.java/issues/2730 (will adopt after TCGC released) https://github.com/Azure/autorest.java/issues/2731 (done)

haolingdong-msft commented 5 days ago

First API view to show the API diff. Though there are 500+ file diffs, there are just very few public API change. As most file diffs are due to descipription change and adding "accept" and "content-type" header. https://apiview.dev/Assemblies/Review/e0cf256f814e456bac0f0d751bd4aa9f/81e4187324194e33899d9cbb375aeb4a?diffRevisionId=46902be02c1b4f0cbe9f89e2a5137a05&diffOnly=true

There are not much public API diff. Existing API diffs are caused by below cases:

  1. client structure case: The latest revision does not generate for cadl-ranch client structure case (https://github.com/Azure/cadl-ranch/tree/main/packages/cadl-ranch-specs/http/client/structure), as it has compile error, and depends on TCGC issue: https://github.com/Azure/typespec-azure/issues/1060
  2. anonymous parameter name change: for flattened parameter (which is also anonymous model) case, if we use the name from TCGC, we will have generation error. So I did not use the parameter name from TCGC for anonymous model.
  3. ARM case's endpoint cannot be set: this is pending on TypeSpec team's fix. issue: https://github.com/Azure/typespec-azure/issues/217
  4. api version is added to builder when there are multiple servers - still wip on this.

There are other issues not showing on public API:

  1. parameter description change
  2. "content-type" added to page get operation. image update: checked the TCGC output and our code, we may need to specially handle the get next page operation to remove the "content-type" added by TCGC for the paging operation.
  3. if it has request body, content type will always be added. So the code is like below: image

I am also checking and will update the progress in this comment.