From 2a9846f49d68906ae70ecf2372286e3d45492f76 Mon Sep 17 00:00:00 2001 From: Jamie Mauro <102264829+jdcmsd@users.noreply.github.com> Date: Mon, 30 Sep 2024 17:46:18 -0400 Subject: [PATCH] Fixing 406 errors on WF API octet-stream endpoints (#30168) ### Proposed Changes * Changed type expectations in Swagger annotations to octet-stream * Updated return type documentation * Added manual examples to provide both an accurate response schema and a workable, simple model for a request payload. ### Checklist - [ ] Tests - [ ] Translations - [ ] Security Implications Contemplated (add notes if applicable) --- .../api/v1/workflow/WorkflowResource.java | 156 +++++++++++++++--- 1 file changed, 137 insertions(+), 19 deletions(-) diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java b/dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java index 47af0f6af53d..b764d17b651a 100644 --- a/dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java +++ b/dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java @@ -2477,7 +2477,7 @@ public final Response findStepById(@Context final HttpServletRequest request, @Produces({MediaType.APPLICATION_JSON, "application/javascript"}) @Consumes(MediaType.MULTIPART_FORM_DATA) @Operation(operationId = "putFireActionByNameMultipart", summary = "Fire action by name (multipart form) \uD83D\uDEA7", - description = "(**Construction notice:** Still awaiting request body documentation. Coming soon!)\n\n" + + description = "(**Construction notice:** Still needs request body documentation. Coming soon!)\n\n" + "Fires a [workflow action](https://www.dotcms.com/docs/latest/managing-workflows#Actions), " + "specified by name, on a target contentlet. Uses a multipart form to transmit its data.\n\n" + "Returns a map of the resultant contentlet, with an additional " + @@ -3114,16 +3114,67 @@ public final Response fireActionDefaultSinglePart(@Context final HttpServletRequ //@Produces({MediaType.APPLICATION_JSON, "application/javascript"}) @Consumes(MediaType.APPLICATION_JSON) @Produces("application/octet-stream") - @Operation(operationId = "postFireSystemActionByNameMulti", summary = "Fire system action by name over multiple contentlets \uD83D\uDEA7", - description = "(**Construction notice:** This endpoint currently cannot succeed on calls through the playground, " + - "though curl and other methods work fine.)\n\n" + - "Fire a [default system action](https://www.dotcms.com/docs/latest/managing-workflows#DefaultActions) " + - "by name on multiple target contentlets.", + @Operation(operationId = "postFireSystemActionByNameMulti", summary = "Fire system action by name over multiple contentlets", + description = "Fire a [default system action](https://www.dotcms.com/docs/latest/managing-workflows#DefaultActions) " + + "by name on multiple target contentlets.\n\nReturns a list of resultant contentlet maps, each with an additional " + + "`AUTO_ASSIGN_WORKFLOW` property, which can be referenced by delegate " + + "services that handle automatically assigning workflow schemes to content with none.", tags = {"Workflow"}, responses = { @ApiResponse(responseCode = "200", description = "Fired action successfully", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = ResponseEntityView.class) + content = @Content(mediaType = "application/octet-stream", + schema = @Schema(implementation = ResponseEntityView.class), + examples = @ExampleObject(value = "{\n" + + " \"entity\": {\n" + + " \"results\": [\n" + + " {\n" + + " \"c2701eced2b59f0bbd55b3d9667878ce\": {\n" + + " \"AUTO_ASSIGN_WORKFLOW\": false,\n" + + " \"archived\": false,\n" + + " \"baseType\": \"string\",\n" + + " \"body\": \"string\",\n" + + " \"body_raw\": \"string\",\n" + + " \"contentType\": \"string\",\n" + + " \"creationDate\": 1725051866540,\n" + + " \"folder\": \"string\",\n" + + " \"hasLiveVersion\": false,\n" + + " \"hasTitleImage\": false,\n" + + " \"host\": \"string\",\n" + + " \"hostName\": \"string\",\n" + + " \"identifier\": \"c2701eced2b59f0bbd55b3d9667878ce\",\n" + + " \"inode\": \"string\",\n" + + " \"languageId\": 1,\n" + + " \"live\": false,\n" + + " \"locked\": false,\n" + + " \"modDate\": 1727438483022,\n" + + " \"modUser\": \"string\",\n" + + " \"modUserName\": \"string\",\n" + + " \"owner\": \"string\",\n" + + " \"ownerName\": \"string\",\n" + + " \"publishDate\": 1727438483051,\n" + + " \"publishUser\": \"string\",\n" + + " \"publishUserName\": \"string\",\n" + + " \"sortOrder\": 0,\n" + + " \"stInode\": \"string\",\n" + + " \"title\": \"string\",\n" + + " \"titleImage\": \"string\",\n" + + " \"url\": \"string\",\n" + + " \"working\": false\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"summary\": {\n" + + " \"affected\": 1,\n" + + " \"failCount\": 0,\n" + + " \"successCount\": 1,\n" + + " \"time\": 45\n" + + " }\n" + + " },\n" + + " \"errors\": [],\n" + + " \"i18nMessagesMap\": {},\n" + + " \"messages\": [],\n" + + " \"permissions\": []\n" + + "}") ) ), @ApiResponse(responseCode = "400", description = "Bad request"), // invalid param string like `\` @@ -3196,7 +3247,16 @@ public final Response fireMultipleActionDefault(@Context final HttpServletReques "[the Wikipedia entry listing tz database time zones]" + "(https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). |\n\n", content = @Content( - schema = @Schema(implementation = FireMultipleActionForm.class) + schema = @Schema(implementation = FireMultipleActionForm.class), + examples = @ExampleObject(value = "{\n" + + " \"contentlet\": [\n" + + " {\n" + + " \"identifier\": \"d684c0a9abeeeceea8b9a7e32fc272ae\"\n" + + " },\n" + + " { \"identifier\": \"c2701eced2b59f0bbd55b3d9667878ce\" }\n" + + " ],\n" + + " \"comments\": \"test comment\"\n" + + "}") ) ) final FireMultipleActionForm fireActionForm) throws DotDataException, DotSecurityException { @@ -3347,19 +3407,70 @@ private void saveMultipleContentletsByDefaultAction(final List