1

I want to generate a client based on an openapi spec and followed the instructions here: https://docs.quarkiverse.io/quarkus-openapi-generator/dev/client.html

Using Quarkus version 3.22.2 and quarkus-openapi-generator 2.10.0

My project has nothing but the openapi yml file in the main/resources folder, an empty beans.xml file in main/resources/META-INF and the following in the application.properties file:

quarkus.openapi-generator.codegen.input-base-dir=src/main/resources
quarkus.openapi-generator.codegen.spec.addressapi_yaml.mutiny=true
quarkus.openapi-generator.codegen.spec.addressapi_yaml.mutiny.return-response=true
platform.quarkus.native.builder-image=false

My pom.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>quarkus-openapi-client</artifactId>
<version>development-SNAPSHOT</version>

<properties>
    <quarkus.platform.version>3.22.2</quarkus.platform.version>
</properties>

<dependencyManagement>
    <dependencies>
        <!-- Quarkus -->
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest</artifactId>
            <version>${quarkus.platform.version}</version>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.openapi.generator</groupId>
            <artifactId>quarkus-openapi-generator</artifactId>
            <version>2.10.0</version>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest-client-jackson</artifactId>
            <version>${quarkus.platform.version}</version>
        </dependency>

        <!-- other -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.19.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <!-- Quarkus -->
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkiverse.openapi.generator</groupId>
        <artifactId>quarkus-openapi-generator</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-rest-client-jackson</artifactId>
    </dependency>

    <!-- other -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-maven-plugin</artifactId>
            <version>${quarkus.platform.version}</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <goals>
                        <goal>build</goal>
                        <goal>generate-code</goal>
                        <goal>generate-code-tests</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>


        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.14.0</version>
            <configuration>
                <parameters>true</parameters>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.5.2</version>
            <configuration>
                <systemPropertyVariables>
                    <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    <maven.home>${maven.home}</maven.home>
                </systemPropertyVariables>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.5.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <systemPropertyVariables>
                    <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                    <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    <maven.home>${maven.home}</maven.home>
                </systemPropertyVariables>
            </configuration>
        </plugin>
    </plugins>
</build> </project>

When building with maven, I get the following error:

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:3.22.2:build (default) on project quarkus-openapi-client: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: jakarta.enterprise.inject.spi.DeploymentException: Found 2 deployment problems: [ERROR] 1 Unsatisfied dependency for type io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider and qualifiers [@OpenApiSpec(openApiSpecId = "addressapi_yml")] [ERROR] - injection target: org.openapi.quarkus.addressapi_yml.api.auth.CompositeAuthenticationProvider#compositeProvider [ERROR] - declared on CLASS bean [types=[jakarta.ws.rs.client.ClientRequestFilter, java.lang.Object, org.openapi.quarkus.addressapi_yml.api.auth.CompositeAuthenticationProvider], qualifiers=[@Default, @Any], target=org.openapi.quarkus.addressapi_yml.api.auth.CompositeAuthenticationProvider] [ERROR] The following classes match by type, but have been skipped during discovery: [ERROR] - io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider has no bean defining annotation (scope, stereotype, etc.)
[ERROR] [ERROR] [ERROR] 2 Unsatisfied dependency for type io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider and qualifiers [@OpenApiSpec(openApiSpecId = "addressapi_yml")] [ERROR] - injection target: parameter 'compositeProvider' of org.openapi.quarkus.addressapi_yml.api.auth.AuthenticationPropagationHeadersFactory constructor [ERROR] - declared on CLASS bean [types=[io.quarkiverse.openapi.generator.providers.AbstractAuthenticationPropagationHeadersFactory, org.openapi.quarkus.a ddressapi_yml.api.auth.AuthenticationPropagationHeadersFactory, org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory, java.lang.Object], qualifiers=[@Default, @Any], target=org.openapi.quarkus.addressapi_yml.api.auth.AuthenticationPropagationHeadersFactory] [ERROR] The following classes match by type, but have been skipped during discovery: [ERROR] - io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider has no bean defining annotation (scope, stereotype, etc.)
[ERROR] [ERROR] [ERROR] at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1589) [ERROR] at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:338) [ERROR] at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:178) [ERROR] at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:488) [ERROR] at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733) [ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:255) [ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654) [ERROR] at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594) [ERROR] at java.base/java.lang.Thread.run(Thread.java:1583) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:499) [ERROR] Suppressed: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider and qualifiers [@OpenApiSpec(openApiSpecId = "addressapi_yml")] [ERROR] - injection target: org.openapi.quarkus.addressapi_yml.api.auth.CompositeAuthenticationProvider#compositeProvider [ERROR] - declared on CLASS bean [types=[jakarta.ws.rs.client.ClientRequestFilter, java.lang.Object, org.openapi.quarkus.addressapi_yml.api.auth.CompositeAuthenticationProvider], qualifiers=[@Default, @Any], target=org.openapi.quarkus.addressapi_yml.api.auth.CompositeAuthenticationProvider] [ERROR] The following classes match by type, but have been skipped during discovery: [ERROR] - io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider has no bean defining annotation (scope, stereotype, etc.)
[ERROR] [ERROR] [ERROR] at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:547) [ERROR] at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:689) [ERROR] at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:323) [ERROR] ... 12 more [ERROR] Suppressed: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider and qualifiers [@OpenApiSpec(openApiSpecId = "addressapi_yml")] [ERROR] - injection target: parameter 'compositeProvider' of org.openapi.quarkus.addressapi_yml.api.auth.AuthenticationPropagationHeadersFactory constructor [ERROR] - declared on CLASS bean [types=[io.quarkiverse.openapi.generator.providers.AbstractAuthenticationPropagationHeadersFactory, org.openapi.quarkus.a ddressapi_yml.api.auth.AuthenticationPropagationHeadersFactory, org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory, java.lang.Object], qualifiers=[@Default, @Any], target=org.openapi.quarkus.addressapi_yml.api.auth.AuthenticationPropagationHeadersFactory] [ERROR] The following classes match by type, but have been skipped during discovery: [ERROR] - io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider has no bean defining annotation (scope, stereotype, etc.)
[ERROR] [ERROR] [ERROR] at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:547) [ERROR] at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:689) [ERROR] at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:323) [ERROR] ... 12 more

It says io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider has no bean defining annotation (scope, stereotype, etc.). I have no control over that class. Is there a way for it to be identified as bean ? Or is there something else I am missing ?

Interesting to notice that it runs with no error with the petstore.yaml

Thank you !

2
  • Hi! Thanks for the question, can you please share a reproducer? Commented May 13 at 16:04
  • 1
    Edited the question with all infos Commented May 19 at 12:31

1 Answer 1

1

Thanks for using the extension and reporting this bug.

The problem is that you're missing a few dependencies in your pom.xml file:

<dependency>
    <groupId>io.quarkiverse.openapi.generator</groupId>
    <artifactId>quarkus-openapi-generator-oidc</artifactId>
    <version>2.10.0</version>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-client-oidc-filter</artifactId>
    <version>${quarkus.platform.version}</version>
</dependency>

As stated in the docs: https://docs.quarkiverse.io/quarkus-openapi-generator/dev/client.html#_oauth2_authentication

From version 2.7.0 and onwards you must also add the quarkus-openapi-generator-oidc additional dependency.

This is required because the generated CompositeAuthenticationProvider file will try to inject OIDC-related classes (see the marker annotation):

@jakarta.annotation.Priority(jakarta.ws.rs.Priorities.AUTHENTICATION)
@io.quarkiverse.openapi.generator.markers.OauthAuthenticationMarker(name="AuthorizationCode", openApiSpecId="openapi_yaml")
public class CompositeAuthenticationProvider implements jakarta.ws.rs.client.ClientRequestFilter {

    @jakarta.inject.Inject
    @io.quarkiverse.openapi.generator.OpenApiSpec(openApiSpecId="openapi_yaml")
    io.quarkiverse.openapi.generator.providers.BaseCompositeAuthenticationProvider compositeProvider;

    @java.lang.Override
    public void filter(jakarta.ws.rs.client.ClientRequestContext context) throws java.io.IOException {
        compositeProvider.filter(context);
    };
}

And your OpenAPI spec file requires oauth2:

  securitySchemes:
    AuthorizationCode:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://api.post.ch/OAuth/authorization
          tokenUrl: https://api.post.ch/OAuth/token
          scopes:
            DCAPI_ADDRESS_READ: Read user's addresses
            DCAPI_ADDRESS_READ_MAIN: Read user's main addresses

Additionally, I would recommend removing this entry from your properties file and just rely on the default src/main/openapi directory to clearly identify the spec files location:

#quarkus.openapi-generator.codegen.input-base-dir=src/main/resources

I'll open an issue on our side to break the build in case of OIDC is not found in the classpath.

Cheers!

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for the quick answer ! I missed that in the documentation indeed. Unfortunately, after adding the 2 dependencies, it gives the same error.
@Tchypp Are you sure you added them to the right place? Your pom has dependencyManagement and dependency sections. The right place is in the dependency section. EDIT: I tested locally and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.