我在swagger-ui中生成的输出是:
DocumentChangeSet {
deletes (Collection«DocumentKey», optional),
updates (Collection«AbstractDocument», optional)
}
Collection«DocumentKey» {}
Collection«AbstractDocument» {}有没有办法让它更详细地描述
deletes (Collection«DocumentKey», optional),和updates (Collection«AbstractDocument», optional)会不会给出每个部分的完整分解?
我的日程安排如下:
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.genericModelSubstitutes(DeferredResult.class)
.alternateTypeRules(
newRule(typeResolver.resolve(DeferredResult.class,
typeResolver.resolve(DeferredResult.class,DocumentChangeSet.class)),
DocumentChangeSet.class)
)
.pathMapping("/")
.apiInfo(apiInfo());
}为了添加更多细节,对documentKey和abstractDocument进行了注释。
下面是不带任何注释的DocumentChangeSet类。
public DocumentChangeSet(Collection<? extends AbstractDocument> updates, Collection<DocumentKey> deletes) {
this.updates = ImmutableSet.copyOf(updates);
this.deletes = ImmutableSet.copyOf(deletes);
}
@Override
public String toString() {
return Objects.toStringHelper(this)
.add("updates", updates.size())
.add("deletes", deletes.size())
.toString();
}
public Collection<AbstractDocument> getUpdates() {
return updates;
}
public Collection<DocumentKey> getDeletes() {
return deletes;
}发布于 2016-06-24 18:15:19
swagger的工作方式是,它扫描REST API代码中的注释(这些注释可以是特定的Swagger annotations或JAX-RS annotations,甚至是Jackson annotations),并从中生成JSON。
然后将此swagger.json提供给Swagger UI,并为您生成漂亮的UI页面。
长话短说,使用注解是必要的。
https://stackoverflow.com/questions/38010126
复制相似问题