Skip to content

http-client-java, bug fix on enum variable name #7590

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

Conversation

weidongxu-microsoft
Copy link
Contributor

@weidongxu-microsoft weidongxu-microsoft commented Jun 9, 2025

follow up on #7448

@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 9, 2025
Copy link
Contributor

github-actions bot commented Jun 9, 2025

No changes needing a change description found.

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

This PR addresses a bugfix in the enum member name generation for the HTTP client Java generator. Key changes include:

  • Updating unit tests in CodeNamerTests.java to validate new naming outcomes for various inputs.
  • Refactoring CodeNamer.java to remove redundant special-case handling and adding a new helper method (trimUnderscores) for cleaning leading/trailing underscores.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
CodeNamerTests.java Updated and added test cases to verify the enum member naming logic, including handling of numeric and special character inputs
CodeNamer.java Removed outdated special-case logic and added trimming reprocessing to better handle underscore-only inputs and special character scenarios
Comments suppressed due to low confidence (1)

packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/CodeNamer.java:150

  • While handling the case where the result is an underscore, consider adding tests for inputs that yield multiple underscores or an empty string after trimming to ensure consistent behavior.
if (result.equals("_")) {

@weidongxu-microsoft weidongxu-microsoft force-pushed the http-client-java_fix-enum-name branch from d4c6b9a to 7b0271a Compare June 9, 2025 07:08
@weidongxu-microsoft weidongxu-microsoft marked this pull request as ready for review June 9, 2025 07:13
@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@weidongxu-microsoft weidongxu-microsoft added this pull request to the merge queue Jun 9, 2025
Merged via the queue into microsoft:main with commit 93a22ee Jun 9, 2025
25 checks passed
@weidongxu-microsoft weidongxu-microsoft deleted the http-client-java_fix-enum-name branch June 9, 2025 09:33
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.

4 participants