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


Related articles

Java with Notes: Java with Notes


One, the Docket

  • In the last article we just built an empty SwaggerConfig class and didn’t configure it at all.

  • An instance of Swagger is a Docket, so we need to configure Swagger with a Docket.

  • We can see what a Docket is.

    • To achieve theDocumentationPluginInterface. Obviously, this is a documentation plug-in. That’s pretty clear. Swagger implements output via the documentation plugin.
  • Let’s look at the Docket constructor for our return.

    • The constructor needs to be passed inDocumentationType
  • It is obvious that this is the name and version.

  • We usually set to DocumentationType SWAGGER_2.

  • Let’s go back to the methods in Docket.

    • It is obvious that all methods are returnsDocketBy itself, then he must be supportiveChain calls.

Second, the apiInfo ()

  • The constructor

  • Ok! Then we’ll set him up with whatever he needs.

  • @configuration @enablesWagger2 public Class SwaggerConfig {@bean public Docket Docket (){return  new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()); Private ApiInfo ApiInfo () {Contact Contact = new Contact(" big ", "https://juejin.cn/user/2084329779387864/posts", "[email protected]"); Return new ApiInfo (" the big fish with notes ", / / title "Swagger learning", describe "v1.0" / /, / / version "https://juejin.cn/user/2084329779387864/posts", / / organization link contact, / / contact information "Apach 2.0 license," / / "https://juejin.cn/user/2084329779387864/posts", // License connection new ArrayList<>()// extension); }}Copy the code
  • Let’s take a look at the original

  • After configuration

  • ApiInfo () sets Swagger’s document information.

  • Water is healthier! The next article will explain how to configure interface scanning and explain the basic principles.


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