Forum Discussion

gokulak's avatar
gokulak
New Contributor
5 years ago
Solved

Generated swagger.json does not contain @PostMapping API's, it contains only @GetMapping API's

Dear All,

I am new to swagger.

I have implemented swagger2 for springboot microservice and I am able to generate swagger.json file 

but

the swagger.json file does not contain api's which are @PostMapping

the generated swagger.json file contains only @GetMapping API's

 

please give me pointer what I am missing.

 

Below are my swagger implementation details 

1) Controller Class

@ComponentScan("com.mysite")
@RestController
@RequestMapping("/myservice")
public class UserRestController {

@PostMapping("/user/{user_id}/action")
public ResponseEntity<UserActionAPIResponse> invokeUserActionsServiceAll(...) {
...
}


}

 

2) pom.xml

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>

 

3)

@Configuration
@EnableSwagger2
public class SwaggerConfig {

@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.mysite.user.controller"))
.paths(regex("/.*"))
.build();
}

}

 

Please help !!!

Thank you in advance,

Gokula