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

gradle build fails for java-spring-template generated code. #57

Closed
JohnRCatlin opened this issue Jun 3, 2020 · 12 comments
Closed

gradle build fails for java-spring-template generated code. #57

JohnRCatlin opened this issue Jun 3, 2020 · 12 comments
Labels
bug Something isn't working stale

Comments

@JohnRCatlin
Copy link

Describe the bug

The generated code fails to build.

How to Reproduce

The code generated by ..
ag streetlights.yaml @asyncapi/java-spring-template -o generated/java-spring --force-write

fails to build using ...

gradle build

with the following errors ...

> Task :compileJava FAILED
/Users/johncatlin/Documents/asyncapi/generator/api/generated/java-spring/src/main/java/com/asyncapi/model/SentAt.java:30: error: illegal start of expression
    }
    ^
/Users/johncatlin/Documents/asyncapi/generator/api/generated/java-spring/src/main/java/com/asyncapi/service/CommandLinePublisher.java:18: error: <identifier> expected
        publisherService.("Hello World from event.lighting.measured");
                         ^
/Users/johncatlin/Documents/asyncapi/generator/api/generated/java-spring/src/main/java/com/asyncapi/service/PublisherService.java:13: error: <identifier> expected
    void (String data);
        ^
/Users/johncatlin/Documents/asyncapi/generator/api/generated/java-spring/src/main/java/com/asyncapi/service/MessageHandlerService.java:16: error: '(' expected
    public void handleEvent.lighting.measured(Message<?> message) {
                           ^
/Users/johncatlin/Documents/asyncapi/generator/api/generated/java-spring/src/main/java/com/asyncapi/service/MessageHandlerService.java:16: error: <identifier> expected
    public void handleEvent.lighting.measured(Message<?> message) {
                                             ^
/Users/johncatlin/Documents/asyncapi/generator/api/generated/java-spring/src/main/java/com/asyncapi/infrastructure/Config.java:40: error: ';' expected
    private String event.lighting.measuredTopic;
                        ^
/Users/johncatlin/Documents/asyncapi/generator/api/generated/java-spring/src/main/java/com/asyncapi/infrastructure/Config.java:40: error: <identifier> expected
    private String event.lighting.measuredTopic;
                                               ^
7 errors

FAILURE: Build failed with an exception.

Expected behavior

It should build without errors?

@JohnRCatlin JohnRCatlin added the bug Something isn't working label Jun 3, 2020
@github-actions
Copy link

github-actions bot commented Jun 3, 2020

Welcome to AsyncAPI. Thanks a lot for reporting your first issue.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@JohnRCatlin
Copy link
Author

Similar outcome for this ...

ag https://raw.githubusercontent.com/asyncapi/generator/master/test/docs/dummy.yml @asyncapi/java-spring-template -o generated/java-spring --force-write

@fmvilas
Copy link
Member

fmvilas commented Jun 4, 2020

@Tenischev would you mind having a look?

@Tenischev
Copy link
Member

@JohnRCatlin please provide used streetlights.yaml file.
Also, please take into account amqp support is not very stable.
Support of several servers with different protocols like in dummy.yml is not supported very well yet.
Last days i worked on stable support of mqtt #58
Based on some hints from mentioned errors fast fix for Kafka #59

@JohnRCatlin
Copy link
Author

@Tenischev

I've attached as requested.
streetlights.yaml.zip

@Tenischev
Copy link
Member

Thank you @JohnRCatlin another part of fix in #62

Please pay attention that in #58 operationId was declared as MUST for each operation, otherwise it's difficult to give a method/variable name based on channel name.

@Tenischev
Copy link
Member

Hey @JohnRCatlin , all PR closed, please check again.
Also, from my previous comment:

Please pay attention that in #58 operationId was declared as MUST for each operation, otherwise it's difficult to give a method/variable name based on channel name.

@JohnRCatlin
Copy link
Author

JohnRCatlin commented Jun 23, 2020

Hi @Tenischev

Sorry to be slow responding.
Thanks for looking at this I really appreciate it 👍

I've just discovered the spectral linter, which I'll now include in my 'pre-generate' procedure.

It should help stop this sort of 'user error' going forwards 🤓

@JohnRCatlin
Copy link
Author

JohnRCatlin commented Jun 23, 2020

P.S ... I'm wondering if the parser and/or generator could be evolved to pick up these sorts of issues in the future? (perhaps by utilising spectral?)

What are your thoughts? Could this idea work?

@fmvilas
Copy link
Member

fmvilas commented Jun 29, 2020

Hey @JohnRCatlin! It would be a great idea to make both work together but keep in mind that the error you faced here has nothing to do with AsyncAPI itself but with the template. This template makes the existence of operationId mandatory. If you envision another way of making this work together, feel free to open an issue at github.com/asyncapi/parser-js. We would be happy to hear how to make it work :)

@fmvilas
Copy link
Member

fmvilas commented Jun 29, 2020

@Tenischev remember you can make your template fail when it doesn't find the operationId field. This way you can send a more meaningful message to the user explaining that this field is required, and it will fail during the generation process.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 30 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants