0

My output generated in the swagger-ui is:

DocumentChangeSet {
deletes (Collection«DocumentKey», optional),
updates (Collection«AbstractDocument», optional)
}
Collection«DocumentKey» {}
Collection«AbstractDocument» {}

Is there any way to make it go into more detail for the

deletes (Collection«DocumentKey», optional), and updates (Collection«AbstractDocument», optional) to give a full break down of each of these parts?

My docket looks as follows:

    @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());
}

To add more detail both documentKey and abstractDocument are annotated.

Below is the DocumentChangeSet class without any annotations.

    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;
}
Danny Bentley
  • 60
  • 2
  • 9

1 Answers1

1

The way swagger works is, it scans your REST API code for annotations (these could be specific Swagger annotations or JAX-RS annotations, or even Jackson annotations) and generates a JSON out of it.

This swagger.json is then fed to Swagger UI and the beautiful UI page is generated for you.

Long answer short, it is neccesary to use annotations.

Sampada
  • 2,931
  • 7
  • 27
  • 39
  • ok this makes sense as it was picking up the jackson annotations for the other classes, looks like im messing one to bridge the gap between DocumentChangeSet and documentKey – Danny Bentley Jun 24 '16 at 10:17
  • I'm still unable to bridge the gap between DocumentChangeSet and the annotated key, any advice? – Danny Bentley Jun 24 '16 at 11:32