@Test void openapi(final WebTarget target) throws IOException { final ProjectModel projectModel = new ProjectModel(); projectModel.setBuildType("maven"); projectModel.setPackageBase("com.test.openapi"); projectModel.setFamily("SimpleAPI"); try (final InputStream openapiJson = Thread.currentThread().getContextClassLoader().getResourceAsStream("openapi/spec.json")) { projectModel.setOpenapi(Json.createReader(openapiJson).readObject()); } final Map<String, String> files = createZip(projectModel, model -> target .path("project/openapi/zip") .request(MediaType.APPLICATION_JSON_TYPE) .accept("application/zip") .post(Entity.entity(model, MediaType.APPLICATION_JSON_TYPE), InputStream.class)); assertEquals(Stream .of("application/src/main/resources/com/test/openapi/dataset/Messages.properties", "application/src/main/java/com/test/openapi/dataset/APIDataSet.java", "application/src/main/java/com/test/openapi/client/APIClient.java", "application/src/main/resources/com/test/openapi/Messages.properties", "application/src/main/resources/com/test/openapi/connection/Messages.properties", "application/src/main/java/com/test/openapi/package-info.java", "application/.mvn/wrapper/maven-wrapper.properties", "application/.mvn/wrapper/maven-wrapper.jar", "application/src/main/java/com/test/openapi/source/APIConfiguration.java", "application/src/main/resources/com/test/openapi/source/Messages.properties", "application/src/main/java/com/test/openapi/connection/APIConnection.java", "application/mvnw.cmd", "application/mvnw", "application/pom.xml", "application/README.adoc", "application/src/main/java/com/test/openapi/source/APISource.java") .collect(toSet()), files.keySet().stream().filter(it -> !it.endsWith("/")).collect(toSet())); final ServerInfo.Snapshot snapshot = versions.getSnapshot(); Stream .of("application/src/main/resources/com/test/openapi/dataset/Messages.properties", "application/src/main/java/com/test/openapi/dataset/APIDataSet.java", "application/src/main/java/com/test/openapi/client/APIClient.java", "application/src/main/resources/com/test/openapi/Messages.properties", "application/src/main/resources/com/test/openapi/connection/Messages.properties", "application/src/main/java/com/test/openapi/package-info.java", "application/src/main/java/com/test/openapi/source/APIConfiguration.java", "application/src/main/resources/com/test/openapi/source/Messages.properties", "application/src/main/java/com/test/openapi/connection/APIConnection.java", "application/pom.xml", "application/src/main/java/com/test/openapi/source/APISource.java") .forEach(file -> { String name = file.substring(file.lastIndexOf('/') + 1); if (name.equals("Messages.properties")) { name = file .substring("application/src/main/resources/com/test/openapi/".length()) .replace('/', '_'); } final String filePath = "generated/ProjectResourceTest/openapi/" + name; assertEquals(resourceFileToString(filePath) .replace("@runtime.version@", snapshot.getKit()) .replace("@surefire.version@", snapshot.getSurefire()), files.get(file), file); }); }
@POST @Path("zip/form") @Produces("application/zip") public Response createZip(@FormParam("project") final String compressedModel, @Context final Providers providers) { final ProjectModel model = readProjectModel(compressedModel, providers); final String filename = ofNullable(model.getArtifact()).orElse("zip") + ".zip"; return Response.ok().entity((StreamingOutput) out -> { generator.generate(toRequest(model), out); out.flush(); }).header("Content-Disposition", "inline; filename=" + filename).build(); }
ProjectResource { @POST @Path("zip/form") @Produces("application/zip") public Response createZip(@FormParam("project") final String compressedModel, @Context final Providers providers) { final ProjectModel model = readProjectModel(compressedModel, providers); final String filename = ofNullable(model.getArtifact()).orElse("zip") + ".zip"; return Response.ok().entity((StreamingOutput) out -> { generator.generate(toRequest(model), out); out.flush(); }).header("Content-Disposition", "inline; filename=" + filename).build(); } }
ProjectResource { @POST @Path("zip/form") @Produces("application/zip") public Response createZip(@FormParam("project") final String compressedModel, @Context final Providers providers) { final ProjectModel model = readProjectModel(compressedModel, providers); final String filename = ofNullable(model.getArtifact()).orElse("zip") + ".zip"; return Response.ok().entity((StreamingOutput) out -> { generator.generate(toRequest(model), out); out.flush(); }).header("Content-Disposition", "inline; filename=" + filename).build(); }  }
ProjectResource { @POST @Path("zip/form") @Produces("application/zip") public Response createZip(@FormParam("project") final String compressedModel, @Context final Providers providers) { final ProjectModel model = readProjectModel(compressedModel, providers); final String filename = ofNullable(model.getArtifact()).orElse("zip") + ".zip"; return Response.ok().entity((StreamingOutput) out -> { generator.generate(toRequest(model), out); out.flush(); }).header("Content-Disposition", "inline; filename=" + filename).build(); }  @GET @Path("configuration") @Produces(MediaType.APPLICATION_JSON) FactoryConfiguration getConfiguration(); @POST @Path("github") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Result createOnGithub(final GithubProject project); @POST @Path("openapi/github") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Result createOpenAPIOnGithub(final GithubProject project); @POST @Path("zip/form") @Produces("application/zip") Response createZip(@FormParam("project") final String compressedModel, @Context final Providers providers); @POST @Path("openapi/zip/form") @Produces("application/zip") Response createOpenAPIZip(@FormParam("project") final String compressedModel,
            @Context final Providers providers); @POST @Path("zip") @Produces("application/zip") @Consumes(MediaType.APPLICATION_JSON) StreamingOutput createZip(final ProjectModel model); @POST @Path("openapi/zip") @Produces("application/zip") @Consumes(MediaType.APPLICATION_JSON) StreamingOutput createOpenAPIZip(final ProjectModel model); }
ProjectResource { @POST @Path("zip/form") @Produces("application/zip") public Response createZip(@FormParam("project") final String compressedModel, @Context final Providers providers) { final ProjectModel model = readProjectModel(compressedModel, providers); final String filename = ofNullable(model.getArtifact()).orElse("zip") + ".zip"; return Response.ok().entity((StreamingOutput) out -> { generator.generate(toRequest(model), out); out.flush(); }).header("Content-Disposition", "inline; filename=" + filename).build(); }  @GET @Path("configuration") @Produces(MediaType.APPLICATION_JSON) FactoryConfiguration getConfiguration(); @POST @Path("github") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Result createOnGithub(final GithubProject project); @POST @Path("openapi/github") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Result createOpenAPIOnGithub(final GithubProject project); @POST @Path("zip/form") @Produces("application/zip") Response createZip(@FormParam("project") final String compressedModel, @Context final Providers providers); @POST @Path("openapi/zip/form") @Produces("application/zip") Response createOpenAPIZip(@FormParam("project") final String compressedModel,
            @Context final Providers providers); @POST @Path("zip") @Produces("application/zip") @Consumes(MediaType.APPLICATION_JSON) StreamingOutput createZip(final ProjectModel model); @POST @Path("openapi/zip") @Produces("application/zip") @Consumes(MediaType.APPLICATION_JSON) StreamingOutput createOpenAPIZip(final ProjectModel model);  }