Skip to content
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

Fix for Issue 346 #364

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix for Issue 346 #364

wants to merge 2 commits into from

Conversation

gvensan
Copy link
Collaborator

@gvensan gvensan commented Jan 9, 2025

Description

  • Generate variable names based on the property name (this will ensure variable names confirming to Java standard - like channelName, instead of channel_name)
  • Introduced a methodName construct to method signature based on the generated variable name (previous point)

With this, the duplication of variable names based on the type will be fixed.

Related issue(s)

Fixes #346

@asyncapi-bot
Copy link
Contributor

We require all PRs to follow Conventional Commits specification.
More details 👇🏼

 No release type found in pull request title "Fix for Issue 346". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Copy link

sonarqubecloud bot commented Jan 9, 2025

Copy link
Member

@CameronRushton CameronRushton left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Main blocker is adding a test. I'd be happy to see the original issue's example asyncapi document added in /mocks as asyncapi version 2.0.0 (since that's all we technically support) and have its own snapshot test.

Comment on lines +30 to +40
// This returns a valid method name fro an identifier.
getMethodName(name) {
let ret = _.camelCase(name);
ret = _.upperFirst(ret);

if (ScsLib.javaKeywords.has(ret)) {
ret = `_${ret}`;
}

return ret;
}
Copy link
Member

Choose a reason for hiding this comment

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

I was confused at first because a method shouldn't start with a capital letter, but I see a 'get' or 'set' is prepended to this name in the template. Maybe calling this getMethodNameSuffix would make that clearer.
Also, since this is so close to being the same as getClassName or getIdentifierName, I wonder if we can use those instead. Calling both getClassName and getIdentifierName would do it, but that's weird. Maybe calling getIdentifierName and doing _.upperFirst() is fine.

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.

Duplicate variable names
3 participants