Skip to content

fix: generated code missing import statements when using template extension #244

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

CameronRushton
Copy link
Member

Problem
When generating code using a dynamic topic and both the function names are the same using x-scs-function-name, the function in Application.java returns a Consumer whose java import is missing (java.util.function.Consumer).

Solution
When spec.functionAsConsumer is true, import Consumer. Previously, this said to import Supplier (bug).

Notes
I've also cleaned up the tests; they're separated into different commits, so you can see the fix in the first commit and the cleanup in the next commit.

Related issue(s)
Resolves #225


exports[`template integration tests using the generator should return payload when using x-scs-function-name instead of logging the message 1`] = `
"
import java.util.function.Supplier;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is why this is no good. Should be Consumer.

@@ -0,0 +1,38 @@
components:
Copy link
Member Author

Choose a reason for hiding this comment

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

We already had a file like this for dynamic topics so I made another one here for static ones that ensure uses Function instead of Consumer.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@CameronRushton CameronRushton merged commit 602f8b7 into asyncapi:master Feb 25, 2022
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 0.11.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Generated Code missing import statements when using template extension
3 participants