Quarkus: Swagger ui not included by default when building a native image with dev profile

Created on 13 Dec 2019  路  1Comment  路  Source: quarkusio/quarkus

Describe the bug
I've generated a native image with the dev configuration profile:
mvn package -Pnative -Dquarkus.profile=dev
My objective was to enable swagger-ui on the native image (as in dev mode, swagger-ui being a transitive dependency of openapi).

This was not the case:

  • http://localhost:8080/swagger-ui leads to a "HTTP resource not found" with a native image,
  • it works well with the JVM.

To confirm that, we can clearly see in the log message, when starting a native image, that openapi extension is included but not swagger-ui.

To enable swagger-ui with a native image, I've had to set the quarkus.swagger-ui.always-include propertry to true.

Expected behavior
By reading the documentation, my understanding is that swagger-ui should be enabled when packaging a native image with the dev profile.

To be more general, my understanding is that by packaging a native image with the dev profile, we get the exact same behaviour as in dev mode. If this is not the cas, that should be mentioned in the documentation.

Actual behavior
Setting quarkus.swagger-ui.always-include propertry to true is required to enable swagger-ui even when packaging a native image with the dev profile.

To Reproduce
Steps to reproduce the behavior:

  1. enable openapi extension in dev mode
  2. access http://localhost:8080/swagger-ui: it works!
  3. package a native image with dev profile: mvn package -Pnative -Dquarkus.profile=true
  4. starts the binary image, observes that swagger-ui extension is not included by reading the log message
  5. access http://localhost:8080/swagger-ui: resource not found!
  6. set quarkus.swagger-ui.always-include=true in application properties
  7. re-package the native image en re-run it: it works.

Configuration

# Add your application.properties here, if applicable.
quarkus.resteasy.path=/easypay/api

# Required to benefit from swagger-ui with a native image
quarkus.swagger-ui.always-include=true

# H2 configuration
quarkus.datasource.driver=org.h2.Driver
quarkus.datasource.url=jdbc:h2:tcp://localhost/~/test
quarkus.datasource.username=sa
quarkus.datasource.password=sapwd
quarkus.datasource.initial-size=2
quarkus.datasource.max-size=4
quarkus.datasource.min-size=2

#required to enable swagger-ui with a native image, even built with the dev profile
quarkus.datasource.health.enabled=true

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver: MacOS 10.13.6
  • Output of java -version: OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
  • GraalVM version (if different from Java): 19.2.1
  • Quarkus version or git rev: 1.0.1.FINAL

Additional context
Maybe this is not a bug, but an expected behaviour. But at least it should be mentioned in the documentation that, even when building your native image with the dev profile, you need to set _quarkus.datasource.health.enabled_ to true to enable swagger-ui.

kinbug

>All comments

I add the same issue. Could you add that details in the guide so we don't get stuck with the same problems.

Was this page helpful?
0 / 5 - 0 ratings