Skip to content

fix: remove conversion of attribute keys to camel case #1092

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

Merged
merged 5 commits into from
Jun 11, 2025

Conversation

ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Jun 11, 2025

What does this PR do?

We should not be automatically converting user defined keys to camel case, and instead keep them as it is.
also avoids escapting of HTML characters by replacing <%= with <%-.

Test Plan

before:
Screenshot 2025-06-11 at 1 22 34 PM

after:
Screenshot 2025-06-11 at 1 22 50 PM

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

yes.

@ChiragAgg5k ChiragAgg5k requested a review from Copilot June 11, 2025 07:53
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 removes automatic conversion of user-defined attribute keys to camelCase in the CLI’s type-generation templates, ensuring the original keys are preserved across all target languages.

  • Switched from toCamelCase(attribute.key) to attribute.key in type definitions, constructors, serializers, and accessors
  • Applied the change consistently to TypeScript, Swift, PHP, Kotlin, JavaScript, Java, and Dart templates

Reviewed Changes

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

Show a summary per file
File Description
templates/cli/lib/type-generation/languages/typescript.js.twig Use raw attribute.key in TS type definitions
templates/cli/lib/type-generation/languages/swift.js.twig Preserve original keys in Swift model properties and coding keys
templates/cli/lib/type-generation/languages/php.js.twig Replace camelCased fields and methods with raw keys in PHP
templates/cli/lib/type-generation/languages/kotlin.js.twig Update Kotlin data class to use original keys
templates/cli/lib/type-generation/languages/javascript.js.twig Adjust JSDoc properties to reference original keys
templates/cli/lib/type-generation/languages/java.js.twig Change Java fields, getters, equals, hashCode, toString to raw keys
templates/cli/lib/type-generation/languages/dart.js.twig Use attribute.key in Dart class fields, constructors, and map methods
Comments suppressed due to low confidence (3)

templates/cli/lib/type-generation/languages/java.js.twig:95

  • The template loop uses attr as the iterator but references attribute.key, which is undefined. It should reference attr.key or update the loop variable to match.
Objects.equals(<%- attribute.key %>, that.<%- attribute.key %>)

templates/cli/lib/type-generation/languages/java.js.twig:101

  • Inside the map callback, attribute.key is undefined because the iterator is named attr. It should use attr.key.
return Objects.hash(<%- collection.attributes.map(attr => attribute.key).join(', ') %>);

templates/cli/lib/type-generation/languages/java.js.twig:108

  • Within the Java toString generation loop, attribute.key is not defined (the loop variable is attribute or attr). Ensure the template uses the correct loop variable name.
"<%- attribute.key %>=" + <%- attribute.key %> +

@christyjacob4 christyjacob4 merged commit a31006e into master Jun 11, 2025
37 checks passed
@christyjacob4 christyjacob4 deleted the fix-types-generation branch June 11, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants