Skip to content

http-client-java, escape javadoc for \u #7663

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 4 commits into
base: main
Choose a base branch
from

Conversation

weidongxu-microsoft
Copy link
Contributor

@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

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for a new domainUsername property in the Java HTTP client model and ensures that backslash-unicode sequences in Javadoc are correctly escaped.

  • Introduces domainUsername in the TSP schema and propagates it through the generated model, serializers, and client docs.
  • Implements CodeNamer.escapeIllegalUnicodeEscape to catch invalid \u sequences and plugs it into line and Javadoc comment generation.
  • Adds unit tests for the new escape logic in CodeNamerTests.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
naming.tsp Defined a new domainUsername property with a backslash in its doc string.
DataResponse.java Added domainUsername field, constructor parameter, getter, and JSON (de)serialization handling.
NamingOpsImpl.java Updated operation documentation to include domainUsername.
NamingAsyncClient.java Updated async client Javadoc to include domainUsername.
CodeNamerTests.java Added tests for escapeIllegalUnicodeEscape.
CodeNamer.java Implemented escapeIllegalUnicodeEscape and factored out newStringBuilder.
JavaLineComment.java Plugged escapeIllegalUnicodeEscape into line comments.
JavaJavadocComment.java Plugged escapeIllegalUnicodeEscape into Javadoc comments.
Comments suppressed due to low confidence (1)

packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/naming/models/DataResponse.java:166

  • Add unit tests to verify serialization and deserialization of the new domainUsername property on DataResponse (including null and special characters) to prevent regressions.
jsonWriter.writeStringField("domainUsername", this.domainUsername);

@weidongxu-microsoft weidongxu-microsoft marked this pull request as ready for review June 17, 2025 06:26
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.

client, handle when source contains \u## in doc
3 participants