@@ -0,0 +1,1579 @@
+package com.github.sbugat.samplerest.resource;%0D%0A%0D%0Aimport java.io.File;%0D%0Aimport java.io.IOException;%0D%0A%0D%0Aimport javax.inject.Inject;%0D%0Aimport javax.inject.Named;%0D%0Aimport javax.ws.rs.GET;%0D%0Aimport javax.ws.rs.Path;%0D%0Aimport javax.ws.rs.PathParam;%0D%0Aimport javax.ws.rs.core.Response;%0D%0A%0D%0Aimport org.springframework.context.ApplicationContext;%0D%0Aimport org.springframework.security.access.prepost.PreAuthorize;%0D%0A%0D%0Aimport com.github.sbugat.samplerest.exception.NotFoundException;%0D%0Aimport com.google.common.io.Files;%0D%0A%0D%0Aimport io.swagger.annotations.Api;%0D%0Aimport io.swagger.annotations.Authorization;%0D%0A%0D%0A@Path(%22/swagger%22)%0D%0A@Api(%0D%0A%09%09value = %22/swagger%22,%0D%0A%09%09authorizations = %7B @Authorization(%22api_token%22) %7D,%0D%0A%09%09hidden = true)%0D%0A@PreAuthorize(%22hasRole('ROLE_ADMIN')%22)%0D%0A@Named%0D%0Apublic class SwaggerResource %7B%0D%0A%0D%0A%09@Inject%0D%0A%09private ApplicationContext context;%0D%0A%0D%0A%09@GET%0D%0A%09@Path(%22%7Bpath:.*%7D%22)%0D%0A%09public Response getFile(@PathParam(%22path%22) final String path) throws IOException, NotFoundException %7B%0D%0A%0D%0A%09%09final File file = context.getResource(%22/api/swagger/%22 + path).getFile();%0D%0A%0D%0A%09%09// Test if the requested file exists and if it can be read and if the file is %22normal%22%0D%0A%09%09if (!file.exists() %7C%7C !file.canRead() %7C%7C !file.isFile()) %7B%0D%0A%09%09%09throw new NotFoundException(404, %22File not found%22);%0D%0A%09%09%7D%0D%0A%0D%0A%09%09// JavaScript file detection to set the correct MIME type to enable browser execution (blocked by recent browser otherwise)%0D%0A%09%09if (path.endsWith(%22.js%22)) %7B%0D%0A%09%09%09return Response.ok(Files.toByteArray(file), %22application/javascript%22).build();%0D%0A%09%09%7D%0D%0A%09%09return Response.ok(Files.toByteArray(file)).build();%0D%0A%09%7D%0D%0A%7D%0D%0A

Add swagger REST service