-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSP, TCGC adoption, not change enum type to string type for client parameter #2974
Closed
Tracked by
#2931
Comments
github-merge-queue bot
pushed a commit
to microsoft/typespec
that referenced
this issue
Nov 15, 2024
…ng type (#4911) Fix Azure/autorest.java#2974 related with https://gist.github.com/haolingdong-msft/df3f25a048baf83d8fabf5206aacc7db#8-clienttype-will-be-generated-after-adopting-tcgc ## Existing code We change enum type to string type in two classes: 1. ProxyParameterMapper: https://github.com/microsoft/typespec/blob/08384aaf73215343cb75aec26f02a22740730077/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ProxyParameterMapper.java#L69-L71 2. ServiceClientMapper: https://github.com/microsoft/typespec/blob/08384aaf73215343cb75aec26f02a22740730077/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ServiceClientMapper.java#L235-L239 ## Logic in this pr Above classes calls [`SchemaUtil.removeModelFromParameter`](https://github.com/microsoft/typespec/blob/27d1069c252eda4988d221c0a04ca839e4fe1a20/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/SchemaUtil.java#L222) to remove enum type and change it to string type. Currently I modify the logic in `removeModelFromParameter()` to not chang enum type to string type for dataplane path/uri parameters. Would like to hear your thoughts on below: @weidongxu-microsoft @XiaofeiCao 1. The logics can also be put in each Mapper, currently I centralized the logics to `SchemaUtil` class. 2. We may also need to add a flag to control this because it will impact existing libraries. The flag can be named as `path-parameter-enum-as-string`. ----------------------------- ## Latest logics After discussing with Weidong, we aggreed to put the logics into the mappers and keep the type in protocol method be enum as well. 1. Define a protected function `protected boolean isRemoveModelFromParameter(Parameter parameter, IType type)` in both `ProxyParameterMapper` and `ServiceClientMapper`. 2. Override the function in the subclass extends above mappers. In the override function, the logic will be not remove model from parameter if the type is `enum` and parameter location is `client`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
details:
https://gist.github.com/haolingdong-msft/df3f25a048baf83d8fabf5206aacc7db#8-clienttype-will-be-generated-after-adopting-tcgc
The text was updated successfully, but these errors were encountered: