redhat-developer / redhat-developer/vscode-quarkus

inject/restclient not needed for constructor injection in quarkus

Open
#708 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
79
Forks
31
Avg merge
12h 51m
Merged PRs (30d)
6

Description

I get The Rest Client object should have the @Inject and @RestClient annotations to be injected as a CDI bean.microprofile-restclient(InjectAndRestClientAnnotationMissing) with this code for the api code which works fine in Quarkus:

@ApplicationScoped
public class AppHAContext implements IHAContext {

    private HomeAssistantAPI api;
    private HomeAssistantWS ws;

    public AppHAContext(@RestClient HomeAssistantAPI api, HomeAssistantWS ws) {
        this.api = api;
        this.ws = ws;
    }

    @Override
    public HomeAssistantAPI getApi() {
        return api;
    }

    public HomeAssistantWS ws() {
        return ws;
    }
}

quarkus does automatic constructor injection thus @Inject is not required.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the Java constructor example in the issue as the reproduction and trace the diagnostic named microprofile-restclient(InjectAndRestClientAnnotationMissing). Confirm how constructor injection is recognized when @RestClient is present, then verify that the diagnostic no longer reports this valid pattern while still identifying genuinely missing injection annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.