'Duplicate Entries in Swagger

I'm writing an API using the HalBuilder library for HAL representations.

As it stands now, I need to have two different methods for the JSON and HAL representations. As an example, my VersionResource includes the following two methods:

@GET
@ApiOperation(value = "Find all versions", response = Version.class, responseContainer = "List")
@Produces({MediaType.APPLICATION_JSON})
public Response getAsJson() {
    List<Version> versions = repository.selectAll();
    return Response.ok().entity(versions).build();
}

@GET
@ApiOperation(value = "Find all versions", notes="Returns HAL format", response = Representation.class, responseContainer = "List")
@Produces({RepresentationFactory.HAL_JSON})
public Representation getAsHalJson() {
    List<Version> versions = repository.selectAll();
    return this.versionRepresentationFactory.createResourceRepresentation(versions);
}

(Note: I'm sure there's a better way of collapsing these methods, and I'm looking into a way to do that)

But my immediate problem is that using two methods causes duplicate entries in my Swagger documentation:

Swagger UI

Those two GET /versions are effectively the same thing, but they have different return types, so Swagger wants them to be different.

I'd like to collapse those two. What are my options here?

[It's probably worth pointing out that I'm using the Swagger Maven plugin to generate my documentation. The application is also using Guice for DI and Jersey for JSON representations.]



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source