From 1b230352ea8f0f7c205ad75664331e1b0d44b387 Mon Sep 17 00:00:00 2001 From: Sadayuki Furuhashi Date: Mon, 23 Dec 2019 16:45:42 -0800 Subject: [PATCH] Add @Deprecated annotation to deprecated JAX-RS resources for Swagger (#1286) * Add @Deprecated annotation to deprecated JAX-RS resources for Swagger Swagger API document displays endpoints with `@Deprecated` annotation with grayed out. * /api/workflow is also deprecated * Added @ApiOperation("(deprecated)") to visualize at docs.digdag.io/api/ --- digdag-cli/src/main/java/io/digdag/cli/Server.java | 3 ++- .../src/main/java/io/digdag/server/rs/AdminResource.java | 3 +++ .../src/main/java/io/digdag/server/rs/ProjectResource.java | 6 ++++++ .../src/main/java/io/digdag/server/rs/WorkflowResource.java | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/digdag-cli/src/main/java/io/digdag/cli/Server.java b/digdag-cli/src/main/java/io/digdag/cli/Server.java index 0e3440270e..560247e4e8 100644 --- a/digdag-cli/src/main/java/io/digdag/cli/Server.java +++ b/digdag-cli/src/main/java/io/digdag/cli/Server.java @@ -117,7 +117,8 @@ public SystemExitException usage(String error) err.println(" --disable-executor-loop disable workflow executor loop"); err.println(" --disable-scheduler disable scheduler"); err.println(" --disable-local-agent disable local task execution"); - err.println(" --enable-swagger enable swagger api"); + err.println(" --enable-swagger enable swagger api. Do not use in production because CORS"); + err.println(" is also enabled on from any domains with all HTTP methods"); err.println(" -p, --param KEY=VALUE overwrites a parameter (use multiple times to set many parameters)"); err.println(" -H, --header KEY=VALUE a header to include in api HTTP responses"); err.println(" -P, --params-file PATH.yml reads parameters from a YAML file"); diff --git a/digdag-server/src/main/java/io/digdag/server/rs/AdminResource.java b/digdag-server/src/main/java/io/digdag/server/rs/AdminResource.java index af6a34080d..6b388b082f 100644 --- a/digdag-server/src/main/java/io/digdag/server/rs/AdminResource.java +++ b/digdag-server/src/main/java/io/digdag/server/rs/AdminResource.java @@ -9,6 +9,7 @@ import io.digdag.core.session.SessionStoreManager; import io.digdag.core.session.StoredSessionAttemptWithSession; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import javax.ws.rs.GET; import javax.ws.rs.NotFoundException; @@ -39,8 +40,10 @@ public AdminResource( this.tm = tm; } + @Deprecated @GET @Path("/api/admin/attempts/{id}/userinfo") + @ApiOperation("(deprecated)") public Config getUserInfo(@PathParam("id") long id) throws ResourceNotFoundException { diff --git a/digdag-server/src/main/java/io/digdag/server/rs/ProjectResource.java b/digdag-server/src/main/java/io/digdag/server/rs/ProjectResource.java index fbcbbfea4a..041048e3fa 100644 --- a/digdag-server/src/main/java/io/digdag/server/rs/ProjectResource.java +++ b/digdag-server/src/main/java/io/digdag/server/rs/ProjectResource.java @@ -229,8 +229,11 @@ private static StoredProject ensureNotDeletedProject(StoredProject proj) return proj; } + // / style is deprecated. Use /api/projects with filter instead + @Deprecated @GET @Path("/api/project") + @ApiOperation("(deprecated)") public RestProject getProject(@QueryParam("name") String name) throws ResourceNotFoundException { @@ -314,8 +317,11 @@ public RestRevisionCollection getRevisions( }, ResourceNotFoundException.class); } + // / style is deprecated. Use /api/projects/{id}/workflows with filter instead + @Deprecated @GET @Path("/api/projects/{id}/workflow") + @ApiOperation("(deprecated)") public RestWorkflowDefinition getWorkflow(@PathParam("id") int projId, @QueryParam("name") String name, @QueryParam("revision") String revName) throws ResourceNotFoundException { diff --git a/digdag-server/src/main/java/io/digdag/server/rs/WorkflowResource.java b/digdag-server/src/main/java/io/digdag/server/rs/WorkflowResource.java index d90c2cc3ea..bee012226a 100644 --- a/digdag-server/src/main/java/io/digdag/server/rs/WorkflowResource.java +++ b/digdag-server/src/main/java/io/digdag/server/rs/WorkflowResource.java @@ -79,8 +79,11 @@ public WorkflowResource( this.tm = tm; } + // / style is deprecated. Use /api/workflows with filter instead + @Deprecated @GET @Path("/api/workflow") + @ApiOperation("(deprecated)") public RestWorkflowDefinition getWorkflowDefinition( @QueryParam("project") String projName, @QueryParam("revision") String revName,