Reputation: 2144
I'm getting hard time trying to incorporate Swagger into my Spring application. I'm trying to just generate .json
file using com.github.kongchen:swagger-maven-plugin:3.1.0
and io.swagger:swagger-core:1.5.0
for annotations, but generated file is totally empty:
{
"swagger" : "2.0",
"info" : {
"version" : "v1",
"title" : "KVS"
}
}
controller example
@RestController
@Api(
tags = { "k/v" },
value = "Main microservice entrypoint",
produces = "application/json",
consumes = "application/json",
protocols = "http,https"
)
class AbcController {
@ApiOperation(value = "/")
@ApiResponses({
@ApiResponse(code = 200, message = "Request entry", response = KvsEntry.class),
@ApiResponse(code = 404, message = "Entry not found", response = Void.class)
})
@RequestMapping(value = "/", method = RequestMethod.POST)
public ResponseEntity<KvsEntry> create(@Validated @RequestBody KvsEntry kvsEntry) {
kvsEntry = keyValueService.saveEntry(kvsEntry);
return new ResponseEntity<>(kvsEntry, HttpStatus.OK);
}
}
I still can get some results using <springmvc>false</springmvc>
configuration and JAX-RS annotations (not quite correct, i'd say), but that would be quite counterproductive. What may i be doing wrong?
Upvotes: 2
Views: 9026
Reputation: 169
Please check simple sample of working plugin with Spring MVC annotations on this repo:
https://github.com/khipis/swagger-maven-example
Plugin is sensitive on dependencies versions and presence or not of specific annotations.
Upvotes: 3