Azure / autorest.java

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

tsp, unbranded support in codegen #2322

Closed weidongxu-microsoft closed 1 day ago

weidongxu-microsoft commented 1 year ago

11/14

0.11.1 released for a bug fix.

OpenAI demo completed.

11/13

0.11.0 released. We should have OpenAI demo covered.

10/31

Sample SDK https://github.com/Azure/autorest.java/tree/openai/openai-in-typespec/openai-sdk

samvaity generic core https://github.com/samvaity/azure-sdk-for-java/tree/add-huc-client/sdk/generic-sdk-core

10/18

generic core feature branch https://github.com/Azure/azure-sdk-for-java/tree/feature/generic-sdk-core-2/sdk/generic-sdk-core

apiview https://apiview.dev/Assemblies/Review/ad330c0d401e45adb0fde58ac674c3cb#com.generic.core.util.serializer.JsonSerializer

local install

rm -rf ~/.m2/repository/com/generic/
mvn clean install -Dcheckstyle.skip -Dspotbugs.skip -Drevapi.skip -Djacoco.skip -Dcodesnippet.skip -Dmaven.javadoc.skip -Dmaven.test.skip -DskipTests

10/12, from Word file


9/xx (outdated)

Current information on core

So far this is a more "rename" solution.

On codegen

weidongxu-microsoft commented 1 year ago

First, we may act upon 3 major items:

  1. keep most of the codegen unchanged, while generate code which imports from generic core
  2. generate sync method only (client and impl)
  3. avoid ref to Jackson

Generate code which imports from generic core

Consider putting all package/class name of generic core / azure core to a central place. Maybe ClassType if possible, or somewhere deeper that ClassType can refer.

Avoid having it in the wild like in current ProxyMethod https://github.com/Azure/autorest.java/blob/8be668f79a7a6af1b05e6781dfab9acf77191182/javagen/src/main/java/com/azure/autorest/model/clientmodel/ProxyMethod.java#L392-L414

An alternative solution may via a post-process, which may include

This would be a bit like the discarded OpenRewrite solution. <-- since in long term, we targets generic core, post-process may not be very attractive and can be costly to maintain

And eventually, we may have a new meta-option as --generic.

Generate sync method only (client and impl)

We may augment the --sync-methods option to have the behavior of only generate sync method

Avoid ref to Jackson

We should have stream-style-serialization as default.

We also may want to avoid ref to Jackson in generated code (azure-json may still use it, but we may want our code not using it explicitly).

weidongxu-microsoft commented 1 year ago

Client hierarchy

Misc items to remove azure (besides package name)

weidongxu-microsoft commented 1 year ago

related issues and PRs

weidongxu-microsoft commented 1 year ago

11/7

RequestOptions get moved to impl package. There is nothing codegen can do without it.

11/2

remain BinaryData.toObject(Class)  

10/30

10/19

Current gap on generic-core

Important

Things may not support in generic?

Minor (SDK can still work without them)

Moved models

Renamed models

weidongxu-microsoft commented 1 year ago

goal https://github.com/bterlson/openai-in-typespec

.NET apiview https://apiview.dev/Assemblies/Review/625c75e2e03449d3a0e8ad7b07d5a97a

weidongxu-microsoft commented 1 year ago
$ mvn dependency:list
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.generic:openai >-------------------------
[INFO] Building SDK for OpenAi 1.0.0-beta.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ openai ---
[INFO]
[INFO] The following files have been resolved:
[INFO]    org.slf4j:slf4j-api:jar:1.7.36:compile
[INFO]    com.generic:generic-core:jar:1.0.0-beta.1:compile
[INFO]    com.generic:generic-json:jar:1.0.0-beta.1:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.008 s
[INFO] Finished at: 2023-11-02T16:22:51+08:00
[INFO] ------------------------------------------------------------------------

$ find . -type f | xargs grep -iF azure