Skip to content

swagger-ui URL problem #346

Closed
Closed
@xMandrake

Description

@xMandrake

Hi, first I want to thank the authors of the project. We start moved from springfox and the process went quite simple.

But we faced with one point in the maven assembly. In our case, there is a need to build jar without dependencies. All dependencies should be moved to a separate folder. This is necessary for caching docker layers to reduce disk space in our docker image repository.

In this case, files related to the swagger-ui become unavailable, for example URL
GET http://127.0.0.1:8080/swagger-ui/favicon-32x32.png 404

In the same time json spec URL is OK
GET http://127.0.0.1:8080/v3/api-docs 200

spring-boot version: 2.2.2.RELEASE
springdoc version: 1.2.26
maven build setup:

    <build>
        <plugins>
            <!-- Build JAR file WITHOUT dependencies (copy in 'libs' folder) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <outputDirectory>${project.build.directory}/libs</outputDirectory>
                    <overWriteReleases>false</overWriteReleases>
                    <overWriteSnapshots>false</overWriteSnapshots>
                    <overWriteIfNewer>true</overWriteIfNewer>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>libs</classpathPrefix>
                            <mainClass>com.example.Application</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

example project to reproduce issue:
https://github.com/xMandrake/spring-boot-swagger-example

It should be noted that there are no problems with the standard assembly

    <build>
        <plugins>
            <!-- Build JAR file WITH dependencies -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

I tried add webjars dependencies directly

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator</artifactId>
            <version>0.38</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>swagger-ui</artifactId>
            <version>3.24.0</version>
        </dependency>

and run this assembly without jar dependencies. In this case swagger-ui files URLs available, but in webjars subfolder:
http://127.0.0.1:8080/webjars/swagger-ui/favicon-32x32.png

I would be grateful for the help or advice on how to properly configure such an assembly using springdoc

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions