class ApiResource {

    @GET
    @Produces({APPLICATION_JSON, TEXT_HTML})
    @ApiResponses({@ApiResponse(code = 200, message = "Returns JSON or HTML OpenAPI document")})
    public Response api(@Context final Request request) throws IOException {

        final Variant variant = request.selectVariant(VARIANTS);

        final URL url;
        if (variant.getMediaType() == APPLICATION_JSON_TYPE) {
            url = getClass().getResource("/swagger.json");

        } else if (variant.getMediaType() == TEXT_HTML_TYPE) {
            url = getClass().getResource("/swagger.html");

        } else {

            return Response.status(Status.BAD_REQUEST).build();
        }

        return Response.ok(url.openStream(), variant.getMediaType()).build();
    }

}