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

feat: adding support to change the collection type for arrays in Java models #2029

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

borrull
Copy link

@borrull borrull commented Jun 10, 2024

Description

This PR adds support to change the collection type in Java models by introducing a new parameter "javaArrayType" to the generate models command.

Checklist

  • The code follows the project's coding standards and is properly linted (npm run lint).
  • Tests have been added or updated to cover the changes.
  • Documentation has been updated to reflect the changes.
  • All tests pass successfully locally.(npm run test).

Copy link
Contributor

@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

netlify bot commented Jun 10, 2024

Deploy Preview for modelina canceled.

Name Link
🔨 Latest commit 9e88339
🔍 Latest deploy log https://app.netlify.com/sites/modelina/deploys/666684818a675d00084ee617

Copy link

sonarcloud bot commented Jun 10, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
22.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@borrull
Copy link
Author

borrull commented Jun 10, 2024

Created this PR to implement the same as in asyncapi/cli#1437 to address asyncapi/cli#1436 , but being blocked by Sonar due to duplications on test file. Am I missing something here?

Copy link
Sponsor Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

Just one comment ✌️

javaArrayType: Flags.string({
type: 'option',
description: 'Java specific, define which type of array needs to be generated.',
options: ['Array', 'List'],
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
options: ['Array', 'List'],
options: ['array', 'list'],

Lets keep it to all lower case or all upper case options for now ✌️

description: 'Java specific, define which type of array needs to be generated.',
options: ['Array', 'List'],
required: false,
default: 'Array'
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
default: 'Array'
default: 'array'

const fileGenerator = new JavaFileGenerator({ presets });
const fileGenerator = new JavaFileGenerator({
presets,
collectionType: javaArrayType as 'Array' | 'List'
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
collectionType: javaArrayType as 'Array' | 'List'
collectionType: javaArrayType as 'array' | 'list'

test
.stderr()
.stdout()
.command([...generalOptions, 'java', ASYNCAPI_V2_DOCUMENT, `-o=${ path.resolve(outputDir, './java')}`, '--packageName', 'test.pkg', '--javaArrayType=List'])
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
.command([...generalOptions, 'java', ASYNCAPI_V2_DOCUMENT, `-o=${ path.resolve(outputDir, './java')}`, '--packageName', 'test.pkg', '--javaArrayType=List'])
.command([...generalOptions, 'java', ASYNCAPI_V2_DOCUMENT, `-o=${ path.resolve(outputDir, './java')}`, '--packageName', 'test.pkg', '--javaArrayType=list'])

@jonaslagoni
Copy link
Sponsor Member

Created this PR to implement the same as in asyncapi/cli#1437 to address asyncapi/cli#1436 , but being blocked by Sonar due to duplications on test file. Am I missing something here?

Just ignore it 🙂

Copy link
Sponsor Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

C# already use first upper case, so lets stick to it until we get uniform options ✌️

@jonaslagoni jonaslagoni merged commit 4ac03ba into asyncapi:next Jun 11, 2024
22 of 23 checks passed
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 4.0.0-next.49 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jonaslagoni
Copy link
Sponsor Member

@all-contributors please add @borrull for code, test

Copy link
Contributor

@jonaslagoni

I've put up a pull request to add @borrull! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants