0

We are updating our documentation and adding branding for the generated pages. We used the input described here (https://quarkus.io/blog/stylish-api/). However, for some reason, the styling works locally (when starting Quarkus in dev mode) but not running it in a container technology (we tried both OpenShift and Docker images. No css is applied, no logos are altered. Not for the landing page and not for generated swagger pages. Is there some setting / something we need to do additionally to get it working?

The following properties are set in the application.properties

quarkus.swagger-ui.title=Title
quarkus.swagger-ui.filter=true
quarkus.swagger-ui.enable=true
quarkus.swagger-ui.always-include=true

I suspect that none of the additional resources (in META-INF) are picked up by Quarkus when building a container image.

Structure:

\resources
  \META-INF
   application.properties
     beans.xml
     \branding
        logo.png
        style.css
     \resources
        favicon.ico
        index.html

We can see that the /swagger-ui/style.css is different. Running in dev the build process copies style.css from the branding dir to the /swagger-ui. This does (apparantly) not happen when building an image.

The /swagger-ui/ folder is placed under META_INF in the runner jar. It contains the wrong css (the original one). Running quarkus in dev mode apparantly does serve this folder from a different location (probably the branding location and replaces the original.

It's apparently somemthing in the maven build.

Sjaak
  • 3,602
  • 17
  • 29

2 Answers2

1

By default, Swagger UI is only available when Quarkus is started in dev or test mode.

If you want to make it available in production too, you can include the following configuration in your application.properties:

quarkus.swagger-ui.always-include=true

https://quarkus.io/guides/openapi-swaggerui#use-swagger-ui-for-development

Edgar Domingues
  • 930
  • 1
  • 8
  • 17
  • The variable is set to true (otherwise I wouldn't have Swagger at all).. It's that `stylish` is not applied (and it is in dev) – Sjaak Mar 25 '21 at 21:12
0

The quarkus-maven-plugin needs an additional goal (prepare) in order to include the css on the right location.

            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare</goal>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

After this the styling was applied.

Sjaak
  • 3,602
  • 17
  • 29