0

I just started using springdoc-openapi. I want to be able to customize the Swagger for things like background color, logo, etc. Is there a way to do that? I see that springdoc-openapi-ui includes webjars/swagger-ui, but I'd hate to just run a customize version. Would prefer to do it as an update so it doesn't interfere with future upgrades

Just to experiment, I've tried copying the entire swagger-ui distribution to my resources directory: resources/swagger-ui. I've also tried resources/webjars/swagger-ui.

In my pom, I have

       <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>

So it should only use my local version. But I get a 404

GET "/swagger-ui/index.html", parameters={}                                    
Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/webjars/]] 
Resource not found                                                             
Completed 404 NOT_FOUND                                                        

Not sure why it's not finding it at swagger-ui/index.html

Peter Kronenberg
  • 878
  • 10
  • 32

1 Answers1

0

It looks like you need to set some of the variables in the .properties file:

try

springdoc.swagger-ui.path=/swagger   <- sets the url path so you can see localhost:8080/swagger/index.html
springdoc.swagger-ui.enabled=true   <- sets the swagger-ui to enabled
springdoc.api-docs.enabled=true   <- sets the springdoc openapi enpoint to enabled

I would look here for other property setting you might need - such as turning off swagger in production, etc... https://springdoc.org/#properties

As for customization, you will have to create your own .html page and disable the use of the default one.

springdoc.swagger-ui.path=MyNewHtmlFile.html

I think is the property name for setting your own .html file.

meh93
  • 311
  • 4
  • 13