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

Swagger API requests default constructor for Jax-RS Resource #23482

Closed
Denistr opened this issue Feb 7, 2022 · 8 comments
Closed

Swagger API requests default constructor for Jax-RS Resource #23482

Denistr opened this issue Feb 7, 2022 · 8 comments
Labels
area/swagger-ui env/windows Impacts Windows machines kind/bug Something isn't working

Comments

@Denistr
Copy link

Denistr commented Feb 7, 2022

Describe the bug

Quarkus 2.7.0 Final (On 2.4.0.Final it is also reproducable)

Project for reproduce:
https://github.com/Denistr/openapi-quarkusFruits

I have constructor for JAX-RS Resource

 @Inject
    public FruitResource(First first, Second second) {
        this.first=first;
        this.second=second;
    }

And there is no default constructor, while I have swagger's annotation - @Api(value = "/fruits")
At starting of application, I'm getting

2022-02-07 16:53:15,019 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: java.lang.RuntimeException: RESTEASY003190: Could not find constructor for class: org.acme.openapi.swagge
rui.FruitResource
        at io.quarkus.dev.appstate.ApplicationStateNotification.waitForApplicationStart(ApplicationStateNotification.java:51)
        at io.quarkus.runner.bootstrap.StartupActionImpl.runMainClass(StartupActionImpl.java:122)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:145)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:456)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:67)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:150)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:106)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:132)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: java.lang.RuntimeException: RESTEASY003190: Could not find constructor for class: org.acme.openapi.swaggerui.FruitResource

Expected behavior

JAX-RS resources will be initialized without default mandatory constructor

Actual behavior

2022-02-07 16:53:15,019 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: java.lang.RuntimeException: RESTEASY003190: Could not find constructor for class: org.acme.openapi.swagge
rui.FruitResource

How to Reproduce?

No response

Output of uname -a or ver

Microsoft Windows [Version 10.0.19044.1466]

Output of java -version

openjdk version "11" 2018-09-25 OpenJDK Runtime Environment 18.9 (build 11+28) OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.0. Final

Build tool (ie. output of mvnw --version or gradlew --version)

Maven home: C:\Tools\apache-maven-3.8.3 Java version: 11, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11 Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

@Denistr Denistr added the kind/bug Something isn't working label Feb 7, 2022
@quarkus-bot quarkus-bot bot added area/swagger-ui env/windows Impacts Windows machines labels Feb 7, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Feb 7, 2022

/cc @MikeEdgar, @phillip-kruger

@phillip-kruger
Copy link
Member

phillip-kruger commented Feb 7, 2022

Have you tried with OpenAPI rather than Swagger ? So use the annotation from MicroProfile Open API by including the smallrye-openapi extension and remove:

<dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-annotations</artifactId>
      <version>1.5.16</version>
    </dependency>

@Denistr
Copy link
Author

Denistr commented Feb 7, 2022

It's demo app, which I built similar to my work app. Work app is a bit complex and consists of a lot 3rd party libs. I can not introduce quarkus' specific things there, only pure CDI, swagger etc.

@phillip-kruger
Copy link
Member

It's not Quarkus specific, it's MicroProfile. But in the case you need swagger you might need to add reflection config for swagger lib classes.

@Denistr
Copy link
Author

Denistr commented Feb 7, 2022

It works with

<dependency>
      <groupId>org.eclipse.microprofile.openapi</groupId>
      <artifactId>microprofile-openapi-api</artifactId>
      <version>3.0</version>
    </dependency>

Does it mean swagger won't be fully supported in Quarkus OOB?

@phillip-kruger
Copy link
Member

phillip-kruger commented Feb 7, 2022

We might add support for the swagger api/annotations in SmallRye OpenAPI (smallrye/smallrye-open-api#752) , but it's a duplicate, OpenAPI supports all things in Swagger. Also, you do not need to add the MicroProfile api as it will be pulled in by the quarkus openapi extension (that you already have)

@phillip-kruger
Copy link
Member

Closing. Please reopen if needed

@pindaroli
Copy link

config

An example please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/swagger-ui env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants