swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

custom the page title

Open thinkd1ff opened this issue 9 years ago • 4 comments

Q A
Bug or feature request? feature request

Expected Behavior

when i develop a web site,i will open different Swagger-UI pages,but when all page name with title "Swagger UI",i want to custom the page title..

thinkd1ff avatar Aug 18 '17 06:08 thinkd1ff

@rainplus, how are you using Swagger-UI? npm, git clone, something else?

shockey avatar Aug 18 '17 07:08 shockey

@shockey Thanks for reply! I use spring boot,just dependency the jar of

<dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>${swagger.version}</version>
</dependency>

i know all the request except "swagger-ui.html" all is ajax.... At present I use the method is override the page "META-INF/resources/swagger-ui.html",add I want to do,So has any else way to do it ? Or office has a metod to custom the page title? because i really will open too many swagger-api pages.But I can not identify which services they belong to.

thinkd1ff avatar Aug 18 '17 07:08 thinkd1ff

Yeah, so that file actually isn't in our codebase, that's Springfox's. See here: https://github.com/springfox/springfox/blob/master/springfox-swagger-ui/src/web/swagger-ui.html#L5

Swagger-UI doesn't offer a way to control the page title (we don't do anything to the title), but you can control the title of any page with a small JavaScript snippet in your HTML, like this:

<script>
  document.title = "My New Title!"
</script>

shockey avatar Aug 18 '17 07:08 shockey

Thanks

thinkd1ff avatar Aug 18 '17 08:08 thinkd1ff