4

I want to documenting a REST API with Swagger and Spring MVC,

I explore /api-docs URL in Swagger UI

Just like below image.

enter image description here

enter image description here

Have anyone can help me solve two question?

1. I don't know why the description isn't display.
2. how can I show all API in same group

SwaggerConfig.java

@Configuration
@EnableSwagger
public class SwaggerConfig {
  private SpringSwaggerConfig springSwaggerConfig;

  @Autowired
  public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig){
      this.springSwaggerConfig = springSwaggerConfig;
  }

  @Bean
  public SwaggerSpringMvcPlugin customImplementation(){
    return new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
      .apiInfo(apiInfo())
      .includePatterns(".*/rest.*");
    }

  private ApiInfo apiInfo(){
      ApiInfo apiInfo = new ApiInfo(
      "API description", "API for me", 
      "API terms of service", 
      "[email protected]", "", ""
      );
      return apiInfo;
    }

pom.xml

jackson-annotations 2.2.3
jackson-databind 2.2.3
jackson-core 2.2.3
guava 14.0
swagger-springmvc 1.0.2
swagger-core_2.10 1.3.7

ServletConifg

.......
@Configuration
@ComponentScan(basePackages = {"config.swagger"})
public class ServletConfig{ 
.......

Controller.java

@Controller
@RequestMapping(value = "/rest/v1")
@Api(value = "CounponController" ,description="SCCCCCC")
public class CouponController {
........

http://localhost:8080/coupon/api-docs

{"apiVersion":"1.0","apis":[{"description":"SCCCCCC","path":"/default/counponcontroller","position":0},{"description":"Coupon Order Controller","path":"/default/coupon-order-controller","position":0},{"description":"Data Controller","path":"/default/data-controller","position":0},{"description":"Ep Controller","path":"/default/ep-controller","position":0}],"authorizations":{},"info":{"contact":"[email protected]","description":"API for Ez-Conpon","license":"","licenseUrl":"","termsOfServiceUrl":"EzTravel API terms of service","title":"EzTravel"},"swaggerVersion":"1.2"}

If need any information , please tell me

I will be grateful for any help you can provide.

1
  • Did you got any solution for this. I am facing same problem Commented Oct 12, 2016 at 6:15

2 Answers 2

2

I'm not sure about Spring-MVC take on Swagger, but I hope you could use my research on Swagger 1.5 to shed a watery light on your situation. I used your questions (and shared your shared image) to build up mine, so I'm sure it can provide you with partial assistance.

Sign up to request clarification or add additional context in comments.

Comments

1

Regarding the first question its because your using the wrong swagger-core dependency. Try using the following dependency com.wordnik:swagger-annotations:1.3.11 (gradle artifact representation)

Will post in detail about the second question in a bit

1 Comment

I am facing same problem. and I have tried by adding same dependency as mentioned by you, but my problem is not solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.