You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by se...@apache.org on 2021/09/18 23:28:42 UTC

[openmeetings] branch feature/OPENMEETINGS-2667-update-schema-definition-for-response-wrapping-in-root-element updated: OPENMEETINGS-2667 Update FileService to have correct schema definition and an example response.

This is an automated email from the ASF dual-hosted git repository.

sebawagner pushed a commit to branch feature/OPENMEETINGS-2667-update-schema-definition-for-response-wrapping-in-root-element
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/feature/OPENMEETINGS-2667-update-schema-definition-for-response-wrapping-in-root-element by this push:
     new b949e0c  OPENMEETINGS-2667 Update FileService to have correct schema definition and an example response.
b949e0c is described below

commit b949e0c9f19d606c2e8aaf911df7a97f1115dc18
Author: Sebastian Wagner <se...@gmail.com>
AuthorDate: Sun Sep 19 11:28:29 2021 +1200

    OPENMEETINGS-2667 Update FileService to have correct schema definition and an example response.
---
 .../openmeetings/webservice/FileWebService.java    | 16 +++--
 .../schema/FileExplorerObjectWrapper.java          | 79 ++++++++++++++++++++++
 .../webservice/schema/FileItemDTOListWrapper.java  | 60 ++++++++++++++++
 .../webservice/schema/FileItemDTOWrapper.java      | 56 +++++++++++++++
 4 files changed, 204 insertions(+), 7 deletions(-)

diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java
index 65b4391..5642c2f 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java
@@ -52,6 +52,9 @@ import org.apache.openmeetings.db.util.AuthLevelUtil;
 import org.apache.openmeetings.util.process.ProcessResultList;
 import org.apache.openmeetings.webservice.error.InternalServiceException;
 import org.apache.openmeetings.webservice.error.ServiceException;
+import org.apache.openmeetings.webservice.schema.FileExplorerObjectWrapper;
+import org.apache.openmeetings.webservice.schema.FileItemDTOListWrapper;
+import org.apache.openmeetings.webservice.schema.FileItemDTOWrapper;
 import org.apache.openmeetings.webservice.schema.ServiceResultWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -60,7 +63,6 @@ import org.springframework.stereotype.Service;
 
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.media.ArraySchema;
 import io.swagger.v3.oas.annotations.media.Content;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -185,7 +187,7 @@ public class FileWebService extends BaseWebService {
 					+ " externalUserId/externalUserType to a valid USER",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "Object created",
-						content = @Content(schema = @Schema(implementation = FileItemDTO.class))),
+						content = @Content(schema = @Schema(implementation = FileItemDTOWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -234,7 +236,7 @@ public class FileWebService extends BaseWebService {
 			description = "Get all files by external type",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "the list of files for given external type",
-						content = @Content(array = @ArraySchema(schema = @Schema(implementation = FileItemDTO.class)))),
+						content = @Content(schema = @Schema(implementation = FileItemDTOListWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -264,7 +266,7 @@ public class FileWebService extends BaseWebService {
 			description = "Get a File Explorer Object by a given ROOM",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "File Explorer Object by a given ROOM",
-							content = @Content(schema = @Schema(implementation = FileExplorerObject.class))),
+							content = @Content(schema = @Schema(implementation = FileExplorerObjectWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -309,7 +311,7 @@ public class FileWebService extends BaseWebService {
 			description = "Get list of FileItemDTO by parent",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "list of file explorer items",
-							content = @Content(array = @ArraySchema(schema = @Schema(implementation = FileItemDTO.class)))),
+							content = @Content(schema = @Schema(implementation = FileItemDTOListWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -355,7 +357,7 @@ public class FileWebService extends BaseWebService {
 			description = "update a file or folder name",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "resulting file object",
-							content = @Content(schema = @Schema(implementation = FileItemDTO.class))),
+							content = @Content(schema = @Schema(implementation = FileItemDTOWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
@@ -393,7 +395,7 @@ public class FileWebService extends BaseWebService {
 			description = "move a file or folder",
 			responses = {
 					@ApiResponse(responseCode = "200", description = "resulting file object",
-							content = @Content(schema = @Schema(implementation = FileItemDTO.class))),
+							content = @Content(schema = @Schema(implementation = FileItemDTOWrapper.class))),
 					@ApiResponse(responseCode = "500", description = "Error in case of invalid credentials or server error")
 			}
 		)
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/FileExplorerObjectWrapper.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/FileExplorerObjectWrapper.java
new file mode 100644
index 0000000..9381975
--- /dev/null
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/FileExplorerObjectWrapper.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.webservice.schema;
+
+import org.apache.openmeetings.db.dto.file.FileExplorerObject;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+
+/**
+ *
+ * @author Sebastian.wagner
+ *
+ * Provide the correct schema response including the wrapping root element + add example response.
+ *
+ * See https://issues.apache.org/jira/browse/OPENMEETINGS-2667
+ *
+ */
+@Schema(example = "{\n"
+		+ "    \"fileExplorerObject\": {\n"
+		+ "        \"userHome\": {\n"
+		+ "            \"id\": 2,\n"
+		+ "            \"name\": \"OpenMeetings-NodeJS-Use-Case_preview.jpg\",\n"
+		+ "            \"hash\": \"f802b727-5bfc-4273-8c90-939ea15bf388\",\n"
+		+ "            \"ownerId\": 1,\n"
+		+ "            \"size\": 391449,\n"
+		+ "            \"type\": \"IMAGE\",\n"
+		+ "            \"width\": 2193,\n"
+		+ "            \"height\": 1823\n"
+		+ "        },\n"
+		+ "        \"roomHome\": [\n"
+		+ "            {\n"
+		+ "                \"id\": 4,\n"
+		+ "                \"name\": \"Folder1\",\n"
+		+ "                \"hash\": \"fad982f0-2468-4b10-9b6c-be3648f55143\",\n"
+		+ "                \"roomId\": 7,\n"
+		+ "                \"type\": \"FOLDER\"\n"
+		+ "            },\n"
+		+ "            {\n"
+		+ "                \"id\": 3,\n"
+		+ "                \"name\": \"browsers-768x768.png\",\n"
+		+ "                \"hash\": \"91902c95-9944-435e-a54d-a2b64158758b\",\n"
+		+ "                \"roomId\": 7,\n"
+		+ "                \"size\": 325415,\n"
+		+ "                \"type\": \"IMAGE\",\n"
+		+ "                \"width\": 768,\n"
+		+ "                \"height\": 768\n"
+		+ "            }\n"
+		+ "        ],\n"
+		+ "        \"userHomeSize\": 1444970,\n"
+		+ "        \"roomHomeSize\": 334311\n"
+		+ "    }\n"
+		+ "}")
+public class FileExplorerObjectWrapper {
+	private FileExplorerObject fileExplorerObject;
+
+	public FileExplorerObject getFileExplorerObject() {
+		return fileExplorerObject;
+	}
+
+	public void setFileExplorerObject(FileExplorerObject fileExplorerObject) {
+		this.fileExplorerObject = fileExplorerObject;
+	}
+}
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/FileItemDTOListWrapper.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/FileItemDTOListWrapper.java
new file mode 100644
index 0000000..cb33117
--- /dev/null
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/FileItemDTOListWrapper.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.webservice.schema;
+
+import java.util.List;
+
+import org.apache.openmeetings.db.dto.file.FileItemDTO;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+
+/**
+ *
+ * @author Sebastian.wagner
+ *
+ * Provide the correct schema response including the wrapping root element + add example response.
+ *
+ * See https://issues.apache.org/jira/browse/OPENMEETINGS-2667
+ *
+ */
+@Schema(example = "{\n"
+		+ "  \"fileItemDTO\": [\n"
+		+ "    {\n"
+		+ "      \"id\": 2,\n"
+		+ "      \"name\": \"OpenMeetings-NodeJS-Use-Case_preview.jpg\",\n"
+		+ "      \"hash\": \"f802b727-5bfc-4273-8c90-939ea15bf388\",\n"
+		+ "      \"ownerId\": 1,\n"
+		+ "      \"size\": 391449,\n"
+		+ "      \"type\": \"IMAGE\",\n"
+		+ "      \"width\": 2193,\n"
+		+ "      \"height\": 1823\n"
+		+ "    }\n"
+		+ "  ]\n"
+		+ "}")
+public class FileItemDTOListWrapper {
+	private List<FileItemDTO> fileItemDTO;
+
+	public List<FileItemDTO> getFileItemDTO() {
+		return fileItemDTO;
+	}
+
+	public void setFileItemDTO(List<FileItemDTO> fileItemDTO) {
+		this.fileItemDTO = fileItemDTO;
+	}
+}
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/FileItemDTOWrapper.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/FileItemDTOWrapper.java
new file mode 100644
index 0000000..1acec9a
--- /dev/null
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/FileItemDTOWrapper.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.webservice.schema;
+
+import org.apache.openmeetings.db.dto.file.FileItemDTO;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+
+/**
+ *
+ * @author Sebastian.wagner
+ *
+ * Provide the correct schema response including the wrapping root element + add example response.
+ *
+ * See https://issues.apache.org/jira/browse/OPENMEETINGS-2667
+ *
+ */
+@Schema(example = "{\n"
+		+ "  \"fileItemDTO\": {\n"
+		+ "    \"id\": 2,\n"
+		+ "    \"name\": \"OpenMeetings-NodeJS-Use-Case_preview.jpg\",\n"
+		+ "    \"hash\": \"f802b727-5bfc-4273-8c90-939ea15bf388\",\n"
+		+ "    \"ownerId\": 1,\n"
+		+ "    \"size\": 391449,\n"
+		+ "    \"type\": \"IMAGE\",\n"
+		+ "    \"width\": 2193,\n"
+		+ "    \"height\": 1823\n"
+		+ "  }\n"
+		+ "}")
+public class FileItemDTOWrapper {
+	private FileItemDTO fileItemDTO;
+
+	public FileItemDTO getFileItemDTO() {
+		return fileItemDTO;
+	}
+
+	public void setFileItemDTO(FileItemDTO fileItemDTO) {
+		this.fileItemDTO = fileItemDTO;
+	}
+}