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 77f5211  OPENMEETINGS-2667 Fix GroupService to have correct response 
schema definition and an example value.
77f5211 is described below

commit 77f5211cdb80995fdd3ed930bb9f860527d81659
Author: Sebastian Wagner <seba.wag...@gmail.com>
AuthorDate: Sun Sep 19 11:08:44 2021 +1200

    OPENMEETINGS-2667 Fix GroupService to have correct response schema 
definition and an example value.
---
 .../openmeetings/webservice/GroupWebService.java   |  8 +-
 .../webservice/schema/GroupDTOListWrapper.java     | 58 +++++++++++++
 .../webservice/schema/UserSearchResultWrapper.java | 94 ++++++++++++++++++++++
 3 files changed, 157 insertions(+), 3 deletions(-)

diff --git 
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
index e49ceed..f9608ca 100644
--- 
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
+++ 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
@@ -51,7 +51,9 @@ import org.apache.openmeetings.db.entity.user.Group;
 import org.apache.openmeetings.db.entity.user.GroupUser;
 import org.apache.openmeetings.db.entity.user.User;
 import org.apache.openmeetings.webservice.error.ServiceException;
+import org.apache.openmeetings.webservice.schema.GroupDTOListWrapper;
 import org.apache.openmeetings.webservice.schema.ServiceResultWrapper;
+import org.apache.openmeetings.webservice.schema.UserSearchResultWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -59,7 +61,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;
@@ -133,7 +134,8 @@ public class GroupWebService extends BaseWebService {
        @Operation(
                        description = "Get the list of all groups",
                        responses = {
-                                       @ApiResponse(responseCode = "200", 
description = "list of users", content = @Content(array = @ArraySchema(schema = 
@Schema(implementation = GroupDTO.class)))),
+                                       @ApiResponse(responseCode = "200", 
description = "list of users",
+                                                       content = 
@Content(schema = @Schema(implementation = GroupDTOListWrapper.class))),
                                        @ApiResponse(responseCode = "500", 
description = "Error in case of invalid credentials or server error")
                        }
                )
@@ -298,7 +300,7 @@ public class GroupWebService extends BaseWebService {
                        description = "Search users and return them",
                        responses = {
                                        @ApiResponse(responseCode = "200", 
description = "users found",
-                                               content = @Content(schema = 
@Schema(implementation = UserSearchResult.class))),
+                                               content = @Content(schema = 
@Schema(implementation = UserSearchResultWrapper.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/GroupDTOListWrapper.java
 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/GroupDTOListWrapper.java
new file mode 100644
index 0000000..d1243a4
--- /dev/null
+++ 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/GroupDTOListWrapper.java
@@ -0,0 +1,58 @@
+/*
+ * 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.user.GroupDTO;
+
+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"
+               + "    \"groupDTO\": [\n"
+               + "        {\n"
+               + "            \"id\": 1,\n"
+               + "            \"name\": \"admin\"\n"
+               + "        },\n"
+               + "        {\n"
+               + "            \"id\": 2,\n"
+               + "            \"name\": \"myCMS\"\n"
+               + "        }\n"
+               + "    ]\n"
+               + "}")
+public class GroupDTOListWrapper {
+       private List<GroupDTO> groupDTO;
+
+       public List<GroupDTO> getGroupDTO() {
+               return groupDTO;
+       }
+
+       public void setGroupDTO(List<GroupDTO> groupDTO) {
+               this.groupDTO = groupDTO;
+       }
+}
diff --git 
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/UserSearchResultWrapper.java
 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/UserSearchResultWrapper.java
new file mode 100644
index 0000000..926c514
--- /dev/null
+++ 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/schema/UserSearchResultWrapper.java
@@ -0,0 +1,94 @@
+/*
+ * 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 io.swagger.v3.oas.annotations.media.Schema;
+
+import org.apache.openmeetings.db.dto.user.UserSearchResult;
+
+/**
+ *
+ * @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"
+               + "    \"userSearchResult\": {\n"
+               + "        \"objectName\": 
\"org.apache.openmeetings.db.entity.user.User\",\n"
+               + "        \"records\": 2,\n"
+               + "        \"result\": [\n"
+               + "            {\n"
+               + "                \"address\": {\n"
+               + "                    \"created\": 1631958373000,\n"
+               + "                    \"deleted\": false,\n"
+               + "                    \"country\": \"NZ\",\n"
+               + "                    \"mail\": \"t...@test.com\"\n"
+               + "                },\n"
+               + "                \"id\": 3,\n"
+               + "                \"languageId\": 1,\n"
+               + "                \"login\": \"soapuser\",\n"
+               + "                \"rights\": [\n"
+               + "                    \"ROOM\",\n"
+               + "                    \"SOAP\",\n"
+               + "                    \"DASHBOARD\",\n"
+               + "                    \"ADMIN\",\n"
+               + "                    \"LOGIN\"\n"
+               + "                ],\n"
+               + "                \"timeZoneId\": \"Europe/Berlin\",\n"
+               + "                \"type\": \"USER\"\n"
+               + "            },\n"
+               + "            {\n"
+               + "                \"address\": {\n"
+               + "                    \"created\": 1630191589000,\n"
+               + "                    \"deleted\": false,\n"
+               + "                    \"country\": \"NZ\",\n"
+               + "                    \"mail\": \"seba.wag...@gmail.com\"\n"
+               + "                },\n"
+               + "                \"firstname\": \"firstname\",\n"
+               + "                \"id\": 1,\n"
+               + "                \"languageId\": 1,\n"
+               + "                \"lastname\": \"lastname\",\n"
+               + "                \"login\": \"admin\",\n"
+               + "                \"rights\": [\n"
+               + "                    \"ROOM\",\n"
+               + "                    \"SOAP\",\n"
+               + "                    \"DASHBOARD\",\n"
+               + "                    \"ADMIN\",\n"
+               + "                    \"LOGIN\"\n"
+               + "                ],\n"
+               + "                \"timeZoneId\": \"Europe/Berlin\",\n"
+               + "                \"type\": \"USER\"\n"
+               + "            }\n"
+               + "        ]\n"
+               + "    }\n"
+               + "}")
+public class UserSearchResultWrapper {
+       private UserSearchResult userSearchResult;
+
+       public UserSearchResult getUserSearchResult() {
+               return userSearchResult;
+       }
+
+       public void setUserSearchResult(UserSearchResult userSearchResult) {
+               this.userSearchResult = userSearchResult;
+       }
+}

Reply via email to