1 year ago

#365381

test-img

Peter Kronenberg

Reading static resources in Springboot for custom swagger-ui

`I'm using springdoc-openapi. I want to customize the swagger, so I copied the whole thing to my resources directory

enter image description here

I am also not loading the files from the jar

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
            <version>1.6.6</version>
            <exclusions>
                <exclusion>
                    <groupId>org.webjars</groupId>
                    <artifactId>swagger-ui</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

But I can't seem to serve any files inside swagger-ui. I tried moving it to static/swagger-ui, but I still get a 404.

When the service starts up, it shows

Patterns [/webjars/**, /**, /swagger-ui*/**] in 'resourceHandlerMapping'

So it looks like openapi is adding those resource paths.

But both http://localhost/index.html and http://localhost/swagger-ui/index.html return 404

I am able to go to http://localhost/hello.html, which is in resources/static, one of the default locations for static files. Why can't I read the index.html file that's in the swagger-ui directory, either in resources/swagger-ui or resources/static/swagger-ui

java

spring-boot

swagger-ui

springdoc

0 Answers

Your Answer

Accepted video resources