我的
@EnableSwagger2
带注释的类包含以下方法:
@Bean
public Docket myServiceApi() {
return new Docket(DocumentationType.SWAGGER_2).groupName("My Service API").apiInfo(apiInfo()).select()
.paths(PathSelectors.regex("/api.*")).build()
.alternateTypeRules(
newRule(
typeResolver.resolve(Map.class, String.class, Object.class),
typeResolver.resolve(InputExample.class)
)
)
;
}
在哪里?
InputExample
是一个包含用注释的许多不同属性的类
@ApiModelProperty
.
@ApiOperation(
value = "Do stuff",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE,
response = SomeOutput.class
)
@RequestMapping(
value = "/api/v1/stuff",
method = RequestMethod.POST,
consumes = {MediaType.APPLICATION_JSON_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE}
)
@ApiResponses(
value = {
@ApiResponse(code = 200, message = "Service execution successful"),
@ApiResponse(code = 400, message = "Bad input data"),
@ApiResponse(code = 500, message = "An internal server error occurred"),
@ApiResponse(code = 503, message = "The service is currently unavailable")
}
)
public ResponseEntity<SomeOutput> doServiceStuff(
HttpServletRequest request,
@RequestBody Map<String, Object> inputContent
) throws
ValidationException,
ServiceUnavailableException,
IOException,
WorkflowDocumentProcessingException
{
...
}
遗憾的是,当我运行服务并在Swagger UI上打开端点时,我看到的只是:
旁白:剩下的人
@使能招摇2
-上课确实有效。