“This is the 25th day of my participation in the Gwen Challenge in November. See details: The Last Gwen Challenge in 2021”


Related articles

Java with Notes: Java with Notes


preface

  • Actually, at this point, aboutSwaggerThat’s the end of the basic features.
  • I don’t know if you’re rightSwaggerWhat does the page look like? I don’t look well anyway.
  • So, today to introduce you a fewSwaggerSkin!!
  • Skins are very simple to use, simply by introducing dependencies.

A, the bootstrap – the UI

  • Introducing dependencies:
  • <! <dependency> <groupId>com.github. Xiaoymin </groupId> < artifactId > swagger - the bootstrap - UI < / artifactId > < version > 1.9.1 < / version > < / dependency >Copy the code
  • To restart the project, visit:http://localhost:8080/doc.html
  • The document is displayed in markdown form, and the request address, type, request parameters, example and response parameters of the document are displayed in hierarchical order. The interface document is clear at a glance, which is convenient for developers to connect.

Second, swagger – mg – the UI

  • Introducing dependencies:
  • < the dependency > < groupId > com. Zyplayer < / groupId > < artifactId > swagger - mg - UI < / artifactId > < version > 1.0.6 < / version > </dependency>Copy the code
  • To restart the project, visit:http://127.0.0.1:8080/document.html
  • The UI supports a variety of tree menu displays, but I think the color of all requests is the same, which is somewhat misleading and not clear at a glance!!

Third, knife4j

  • Introducing dependencies:
  • < the dependency > < groupId > com. Making. Xiaoymin < / groupId > < artifactId > knife4j - spring - UI < / artifactId > < version > 2.0.6 < / version > </dependency>Copy the code
  • To restart the project, visit:http://127.0.0.1:8080/doc.html
  • I need to say more about this.
  • Knife4j 2.0.6 or later, Spring Boot must be greater than or equal to 2.2.x, and SpringFox must be the corresponding version.
  • Versions 2.0.6 and later use the @enablesWagger2webMVC annotation, while versions before 2.0.6 use the @enablesWagger2 annotation, which is the same as swagger-bootstrap-UI.

conclusion

  • There’s actually another kind of skinswagger-ui-layer, but since this project has stopped maintenance, it is not compatible with the latest SpringBoot and Swagger. So I will not list them here!
  • There are three types of skin above, and in my experience, the most common is definitelyknife4jThis is the style THAT I usually use.
  • You can choose your skin according to what you like!
  • The above are all personal words, if there is any wrong, welcome to point out.
  • If there are other skin, you are welcome to point out, I will add!
  • SwaggerThis is the end of the series ~ open a new pit tomorrow!

The road ahead is long, I see no end, I will search high and low

If you think I bloggers write well! Writing is not easy, please like, follow, comment and give encouragement to the blogger ~ Hahah