Skip to content

http-client-java, codegen change, support query param reinjection #7668

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

haolingdong-msft
Copy link
Member

Fix Azure/autorest.java#3081

Design:
Azure/autorest.java#3081 (comment)

Code change:

  1. PagingMetadata.java: add nextLinkReInjectedParameterNames property and logics to extract the value from xmsPageable and put to MethodPageDetails.
  2. MethodPageDetails.java: add nextLinkReInjectedParameterNames property and corresponding ctor, getters.
  3. ClientMethodTemplate.java: add logic addQueryParameterReInjectionLogic and apply to both sync and async paging service client method.

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Jun 17, 2025
Copy link
Contributor

No changes needing a change description found.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jun 17, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@haolingdong-msft haolingdong-msft marked this pull request as ready for review June 18, 2025 02:13
@@ -40,6 +40,7 @@ final class PagingMetadata {
private final List<ClientMethod> nextMethods;
private final ClientMethodParameter maxPageSizeParameter;
private final MethodPageDetails.ContinuationToken continuationToken;
private final List<String> nextLinkReInjectedParameterNames;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be in a class e.g. NextLinkReInjection (similar to ContinuationToken)?

As this is a legacy feature, we'd like it to be in its place.

And test would be simplify whether this var is null or not -- List be empty should also mean this var be null.

nit, if only query param is valid, make it in the name of the list (or at least document it).

Comment on lines +95 to +97
if (p.getLanguage() != null && p.getLanguage().getDefault() != null) {
nextLinkReInjectedParameterNames.add(p.getLanguage().getDefault().getName());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be serializedName?

If so, also say it in the name of the List.

@@ -1069,6 +1083,28 @@ private static void addServiceMethodAnnotation(JavaType typeBlock, ReturnType re
typeBlock.annotation("ServiceMethod(returns = ReturnType." + returnType.name() + ")");
}

private static void addQueryParameterReInjectionLogic(List<String> reinjectedParamNames, JavaBlock javaBlock) {
Copy link
Contributor

@weidongxu-microsoft weidongxu-microsoft Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code would be different in clientcore/v2.

If there is subclass for this Template class, use protected + override in its subclass.
If not, use a condition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, clientcore is different, I will change to protected and use override method. Do you think we need to support this feature in clientcore template? I tend to have empty override function in client core template because this feature is for azure only, and currently all azure sdks are using azure core, not client core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:java Issue for the Java client emitter: @typespec/http-client-java
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tsp, Paging: Query parameter re-injection
3 participants