This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git
commit 4b9b9c2d2ea2cf5068373047e5efec8048d43114 Author: heyile <[email protected]> AuthorDate: Mon Nov 5 21:43:10 2018 +0800 [SCB-1007] not support CustomGeneric<Map<String,String>> --- .../org/apache/servicecomb/it/schema/Generic.java} | 11 +- .../org/apache/servicecomb/it/schema/User.java | 76 +++++++ .../org/apache/servicecomb/it/ConsumerMain.java | 5 +- .../servicecomb/it/testcase/TestGenericEdge.java | 88 ++++++++ .../servicecomb/it/testcase/base/TestGeneric.java | 230 ++++++++++++++++++++- .../it-edge/src/main/resources/microservice.yaml | 25 +++ .../servicecomb/it/schema/GenericSchema.java | 101 +++++++++ .../swagger/generator/core/utils/ClassUtils.java | 2 +- 8 files changed, 527 insertions(+), 11 deletions(-) diff --git a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/base/TestGeneric.java b/integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/Generic.java similarity index 85% copy from integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/base/TestGeneric.java copy to integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/Generic.java index 4c85af1..085b2d1 100644 --- a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/base/TestGeneric.java +++ b/integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/Generic.java @@ -14,13 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.it.testcase.base; +package org.apache.servicecomb.it.schema; -import org.junit.Test; - -public class TestGeneric { - @Test - public void test() { - - } +public class Generic<T> { + public T value; } diff --git a/integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/User.java b/integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/User.java new file mode 100644 index 0000000..3f87a94 --- /dev/null +++ b/integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/User.java @@ -0,0 +1,76 @@ +/* + * 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.servicecomb.it.schema; + +import org.apache.servicecomb.foundation.common.utils.JsonUtils; + +import com.fasterxml.jackson.core.JsonProcessingException; + +public class User { + private String name = "nameA"; + + private int age = 100; + + private int index; + + private String[] names; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String[] getNames() { + return names; + } + + public void setNames(String[] names) { + this.names = names; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + @Override + public String toString() { + return "User [name=" + name + ", age=" + age + ", index=" + index + "]"; + } + + public String jsonString() { + try { + return JsonUtils.writeValueAsString(this); + } catch (JsonProcessingException e) { + throw new IllegalStateException(e); + } + } +} diff --git a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java index cbc00d7..8b0a9b5 100644 --- a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java +++ b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java @@ -30,6 +30,7 @@ import org.apache.servicecomb.it.testcase.TestDefaultJsonValueJaxrsSchema; import org.apache.servicecomb.it.testcase.TestDefaultValue; import org.apache.servicecomb.it.testcase.TestDownload; import org.apache.servicecomb.it.testcase.TestDownloadSlowStreamEdge; +import org.apache.servicecomb.it.testcase.TestGenericEdge; import org.apache.servicecomb.it.testcase.TestIgnoreMethod; import org.apache.servicecomb.it.testcase.TestIgnoreStaticMethod; import org.apache.servicecomb.it.testcase.TestParamCodec; @@ -40,6 +41,7 @@ import org.apache.servicecomb.it.testcase.TestRestServerConfig; import org.apache.servicecomb.it.testcase.TestRestServerConfigEdge; import org.apache.servicecomb.it.testcase.TestTrace; import org.apache.servicecomb.it.testcase.TestTraceEdge; +import org.apache.servicecomb.it.testcase.base.TestGeneric; import org.apache.servicecomb.it.testcase.thirdparty.Test3rdPartyInvocation; public class ConsumerMain { @@ -97,7 +99,8 @@ public class ConsumerMain { ITJUnitUtils.runWithHighwayAndRest(TestChangeTransport.class); ITJUnitUtils.runWithHighwayAndRest(TestDataTypePrimitive.class); ITJUnitUtils.runWithHighwayAndRest(TestAnnotatedAttribute.class); - + ITJUnitUtils.runWithRest(TestGeneric.class); + ITJUnitUtils.run(TestGenericEdge.class); // only rest support default value feature ITJUnitUtils.runWithRest(TestDefaultValue.class); diff --git a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestGenericEdge.java b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestGenericEdge.java new file mode 100644 index 0000000..f20380b --- /dev/null +++ b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestGenericEdge.java @@ -0,0 +1,88 @@ +/* + * 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.servicecomb.it.testcase; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.servicecomb.it.extend.engine.GateRestTemplate; +import org.apache.servicecomb.it.schema.Generic; +import org.apache.servicecomb.it.schema.User; +import org.junit.Test; + +public class TestGenericEdge { + private static GateRestTemplate client = GateRestTemplate.createEdgeRestTemplate("generic"); + + @Test + public void testGenericMap() { + Generic<Map<String, String>> mapGeneric = new Generic<>(); + Map<String, String> map = new HashMap<>(); + map.put("test", "hello"); + mapGeneric.value = map; + @SuppressWarnings("unchecked") + Generic<Map<String, String>> result = client.postForObject("/genericMap", mapGeneric, Generic.class); + String test = result.value.get("test"); + assertEquals(test, "hello"); + } + + @Test + public void testGenericMapList() { + Generic<Map<String, List<String>>> mapListGeneric = new Generic<>(); + Map<String, List<String>> map = new HashMap<>(); + List<String> list = new ArrayList<>(); + list.add("hello"); + map.put("test", list); + mapListGeneric.value = map; + @SuppressWarnings("unchecked") + Generic<Map<String, List<String>>> result = client.postForObject("/genericMapList", mapListGeneric, Generic.class); + String test = result.value.get("test").get(0); + assertEquals("hello", test); + } + + @Test + public void testGenericUser() { + Generic<User> generic = new Generic<>(); + generic.value = new User(); + @SuppressWarnings("unchecked") + Generic<Map<String, Object>> result = client.postForObject("/genericUser", generic, Generic.class); + Map<String, Object> resultUser = result.value; + assertEquals("nameA", resultUser.get("name")); + assertEquals(100, resultUser.get("age")); + } + + @Test + @SuppressWarnings("unchecked") + public void testGenericMapListUser() { + Generic<Map<String, List<User>>> mapListUserGeneric = new Generic<>(); + Map<String, List<User>> map = new HashMap<>(); + List<User> list = new ArrayList<>(); + list.add(new User()); + map.put("test", list); + mapListUserGeneric.value = map; + + Generic<Map<String, List<Map<String, Object>>>> result = client + .postForObject("/genericMapListUser", mapListUserGeneric, Generic.class); + Map<String, Object> resultUser = result.value.get("test").get(0); + + assertEquals("nameA", resultUser.get("name")); + assertEquals(100, resultUser.get("age")); + } +} diff --git a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/base/TestGeneric.java b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/base/TestGeneric.java index 4c85af1..bf20ccc 100644 --- a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/base/TestGeneric.java +++ b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/base/TestGeneric.java @@ -16,11 +16,239 @@ */ package org.apache.servicecomb.it.testcase.base; +import static org.junit.Assert.assertEquals; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.apache.servicecomb.it.Consumers; +import org.apache.servicecomb.it.schema.Generic; +import org.apache.servicecomb.it.schema.User; import org.junit.Test; +import org.springframework.http.HttpStatus; public class TestGeneric { + interface GenericIntf { + Holder<User> holderUser(Holder<User> input); + + Generic<User> genericUser(Generic<User> input); + + Generic<Long> genericLong(Generic<Long> input); + + Generic<Date> genericDate(Generic<Date> input); + + Generic<HttpStatus> genericEnum(Generic<HttpStatus> input); + + Generic<Generic<User>> genericGenericUser(Generic<Generic<User>> input); + + Generic<Map<String, String>> genericMap(Generic<Map<String, String>> mapGeneric); + + Generic<Map<String, List<String>>> genericMapList(Generic<Map<String, List<String>>> mapListGeneric); + + Generic<Map<String, List<User>>> genericMapListUser(Generic<Map<String, List<User>>> mapListUserGeneric); + } + + private static Consumers<GenericIntf> consumers = new Consumers<>("generic", GenericIntf.class); + + private String expectUserStr = "{\"name\":\"nameA\",\"age\":100,\"index\":0,\"names\":null}"; + + private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + @Test - public void test() { + public void testHolderUser_intf() { + Holder<User> holder = new Holder<>(new User()); + Holder<User> result = consumers.getIntf().holderUser(holder); + assertEquals(result.value.jsonString(), expectUserStr); + } + @Test + public void testHolderUser_rt() { + Holder<User> holder = new Holder<>(new User()); + @SuppressWarnings("unchecked") + Holder<User> result = consumers.getSCBRestTemplate().postForObject("/holderUser", holder, Holder.class); + assertEquals(result.value.jsonString(), expectUserStr); + } + + @Test + public void testGenericUser_intf() { + Generic<User> generic = new Generic<>(); + generic.value = new User(); + + Generic<User> result = consumers.getIntf().genericUser(generic); + assertEquals(result.value.jsonString(), expectUserStr); + } + + @Test + public void testGenericUser_rt() { + Generic<User> generic = new Generic<>(); + generic.value = new User(); + @SuppressWarnings("unchecked") + Generic<User> result = consumers.getSCBRestTemplate().postForObject("/genericUser", generic, Generic.class); + assertEquals(result.value.jsonString(), expectUserStr); + } + + @Test + public void testGenericLong_intf() { + Generic<Long> generic = new Generic<>(); + generic.value = 100L; + Generic<Long> result = consumers.getIntf().genericLong(generic); + assertEquals(Long.class, result.value.getClass()); + assertEquals(100L, (long) result.value); + } + + @Test + public void testGenericLong_rt() { + Generic<Long> generic = new Generic<>(); + generic.value = 100L; + @SuppressWarnings("unchecked") + Generic<Long> result = consumers.getSCBRestTemplate().postForObject("/genericLong", generic, Generic.class); + assertEquals(Long.class, result.value.getClass()); + assertEquals(100L, (long) result.value); + } + + @Test + public void testGenericDate_intf() { + Generic<Date> generic = new Generic<>(); + generic.value = new Date(1001); + Generic<Date> result = consumers.getIntf().genericDate(generic); + assertEquals(result.value.getClass(), Date.class); + assertEquals("1970-01-01T08:00:01.001Z", simpleDateFormat.format(result.value)); + } + + @Test + public void testGenericDate_rt() { + Generic<Date> generic = new Generic<>(); + generic.value = new Date(1001); + @SuppressWarnings("unchecked") + Generic<Date> result = consumers.getSCBRestTemplate().postForObject("/genericDate", generic, Generic.class); + assertEquals(result.value.getClass(), Date.class); + assertEquals("1970-01-01T08:00:01.001Z", simpleDateFormat.format(result.value)); + } + + @Test + public void testGenericEnum_intf() { + Generic<HttpStatus> generic = new Generic<>(); + generic.value = HttpStatus.OK; + + Generic<HttpStatus> result = consumers.getIntf().genericEnum(generic); + assertEquals(HttpStatus.class, result.value.getClass()); + assertEquals(HttpStatus.OK, result.value); + } + + @Test + public void testGenericEnum_rt() { + Generic<HttpStatus> generic = new Generic<>(); + generic.value = HttpStatus.OK; + @SuppressWarnings("unchecked") + Generic<HttpStatus> result = consumers.getSCBRestTemplate().postForObject("/genericEnum", generic, Generic.class); + assertEquals(HttpStatus.class, result.value.getClass()); + assertEquals(HttpStatus.OK, result.value); + } + + @Test + public void testGenericGenericUser_intf() { + Generic<Generic<User>> generic = new Generic<>(); + generic.value = new Generic<>(); + generic.value.value = new User(); + + Generic<Generic<User>> result = consumers.getIntf().genericGenericUser(generic); + assertEquals(result.value.value.jsonString(), expectUserStr); + } + + @Test + public void testGenericGenericUser_rt() { + Generic<Generic<User>> generic = new Generic<>(); + generic.value = new Generic<>(); + generic.value.value = new User(); + @SuppressWarnings("unchecked") + Generic<Generic<User>> result = consumers.getSCBRestTemplate() + .postForObject("/genericGenericUser", generic, Generic.class); + assertEquals(result.value.value.jsonString(), expectUserStr); + } + + @Test + public void testGenericMap_intf() { + Generic<Map<String, String>> mapGeneric = new Generic<>(); + Map<String, String> map = new HashMap<>(); + map.put("test", "hello"); + mapGeneric.value = map; + Generic<Map<String, String>> result = consumers.getIntf().genericMap(mapGeneric); + String test = result.value.get("test"); + assertEquals(test, "hello"); + } + + @Test + public void testGenericMap_rt() { + Generic<Map<String, String>> mapGeneric = new Generic<>(); + Map<String, String> map = new HashMap<>(); + map.put("test", "hello"); + mapGeneric.value = map; + @SuppressWarnings("unchecked") + Generic<Map<String, String>> result = consumers.getSCBRestTemplate() + .postForObject("/genericMap", mapGeneric, Generic.class); + String test = result.value.get("test"); + assertEquals(test, "hello"); + } + + @Test + public void testGenericListMap_intf() { + Generic<Map<String, List<String>>> mapListGeneric = new Generic<>(); + Map<String, List<String>> map = new HashMap<>(); + List<String> list = new ArrayList<>(); + list.add("hello"); + map.put("test", list); + mapListGeneric.value = map; + Generic<Map<String, List<String>>> result = consumers.getIntf().genericMapList(mapListGeneric); + String test = result.value.get("test").get(0); + assertEquals(test, "hello"); + } + + @Test + public void testGenericListMap_rt() { + Generic<Map<String, List<String>>> mapListGeneric = new Generic<>(); + Map<String, List<String>> map = new HashMap<>(); + List<String> list = new ArrayList<>(); + list.add("hello"); + map.put("test", list); + mapListGeneric.value = map; + @SuppressWarnings("unchecked") + Generic<Map<String, List<String>>> result = consumers.getSCBRestTemplate() + .postForObject("/genericMapList", mapListGeneric, Generic.class); + String test = result.value.get("test").get(0); + assertEquals(test, "hello"); + } + + @Test + public void testGenericListUserMap_intf() { + Generic<Map<String, List<User>>> mapListUserGeneric = new Generic<>(); + Map<String, List<User>> map = new HashMap<>(); + List<User> list = new ArrayList<>(); + list.add(new User()); + map.put("test", list); + mapListUserGeneric.value = map; + Generic<Map<String, List<User>>> result = consumers.getIntf().genericMapListUser(mapListUserGeneric); + String test = result.value.get("test").get(0).jsonString(); + assertEquals(test, expectUserStr); + } + + @Test + public void testGenericListUserMap_rt() { + Generic<Map<String, List<User>>> mapListUserGeneric = new Generic<>(); + Map<String, List<User>> map = new HashMap<>(); + List<User> list = new ArrayList<>(); + list.add(new User()); + map.put("test", list); + mapListUserGeneric.value = map; + @SuppressWarnings("unchecked") + Generic<Map<String, List<User>>> result = consumers.getSCBRestTemplate() + .postForObject("/genericMapListUser", mapListUserGeneric, Generic.class); + String test = result.value.get("test").get(0).jsonString(); + assertEquals(test, expectUserStr); } } diff --git a/integration-tests/it-edge/src/main/resources/microservice.yaml b/integration-tests/it-edge/src/main/resources/microservice.yaml index 888f1dd..59b5580 100644 --- a/integration-tests/it-edge/src/main/resources/microservice.yaml +++ b/integration-tests/it-edge/src/main/resources/microservice.yaml @@ -34,6 +34,11 @@ servicecomb: # emptyAsNull: true operation: it-producer: + generic: + genericUser: + transport: rest + genericMapListUser: + transport: rest download: slowInputStream: transport: rest @@ -43,6 +48,11 @@ servicecomb: queryInput: transport: rest it-producer-h2: + generic: + genericUser: + transport: rest + genericMapListUser: + transport: rest download: slowInputStream: transport: rest @@ -52,6 +62,11 @@ servicecomb: queryInput: transport: rest it-producer-h2c: + generic: + genericUser: + transport: rest + genericMapListUser: + transport: rest download: slowInputStream: transport: rest @@ -61,6 +76,11 @@ servicecomb: queryInput: transport: rest it-producer-deploy-springboot2-servlet: + generic: + genericUser: + transport: rest + genericMapListUser: + transport: rest download: slowInputStream: transport: rest @@ -70,6 +90,11 @@ servicecomb: queryInput: transport: rest it-producer-deploy-springboot2-standalone: + generic: + genericUser: + transport: rest + genericMapListUser: + transport: rest download: slowInputStream: transport: rest diff --git a/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/GenericSchema.java b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/GenericSchema.java new file mode 100644 index 0000000..42f9ce0 --- /dev/null +++ b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/GenericSchema.java @@ -0,0 +1,101 @@ +/* + * 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.servicecomb.it.schema; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.apache.servicecomb.provider.rest.common.RestSchema; +import org.springframework.http.HttpStatus; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; + +@RestSchema(schemaId = "generic") +@RequestMapping(path = "/v1/generic") +public class GenericSchema { + + @PostMapping(path = "/holderUser") + public Holder<User> holderUser(@RequestBody Holder<User> input) { + Assert.isInstanceOf(Holder.class, input); + Assert.isInstanceOf(User.class, input.value); + return input; + } + + @PostMapping(path = "/genericUser") + public Generic<User> genericUser(@RequestBody Generic<User> input) { + Assert.isInstanceOf(Generic.class, input); + Assert.isInstanceOf(User.class, input.value); + return input; + } + + @PostMapping(path = "/genericLong") + public Generic<Long> genericLong(@RequestBody Generic<Long> input) { + Assert.isInstanceOf(Generic.class, input); + Assert.isInstanceOf(Long.class, input.value); + return input; + } + + @PostMapping(path = "/genericDate") + public Generic<Date> genericDate(@RequestBody Generic<Date> input) { + Assert.isInstanceOf(Generic.class, input); + Assert.isInstanceOf(Date.class, input.value); + return input; + } + + @PostMapping(path = "/genericEnum") + public Generic<HttpStatus> genericEnum(@RequestBody Generic<HttpStatus> input) { + Assert.isInstanceOf(Generic.class, input); + Assert.isInstanceOf(HttpStatus.class, input.value); + return input; + } + + @PostMapping(path = "/genericGenericUser") + public Generic<Generic<User>> genericGenericUser(@RequestBody Generic<Generic<User>> input) { + Assert.isInstanceOf(Generic.class, input); + Assert.isInstanceOf(Generic.class, input.value); + Assert.isInstanceOf(User.class, input.value.value); + return input; + } + + @PostMapping(path = "/genericMap") + public Generic<Map<String, String>> genericMap(@RequestBody Generic<Map<String, String>> mapGeneric) { + Assert.isInstanceOf(Generic.class, mapGeneric); + Assert.isInstanceOf(Map.class, mapGeneric.value); + return mapGeneric; + } + + @PostMapping(path = "/genericMapList") + public Generic<Map<String, List<String>>> genericMapList( + @RequestBody Generic<Map<String, List<String>>> mapListGeneric) { + Assert.isInstanceOf(Generic.class, mapListGeneric); + Assert.isInstanceOf(Map.class, mapListGeneric.value); + return mapListGeneric; + } + + @PostMapping(path = "/genericMapListUser") + public Generic<Map<String, List<User>>> genericMapListUser( + @RequestBody Generic<Map<String, List<User>>> mapListUserGeneric) { + Assert.isInstanceOf(Generic.class, mapListUserGeneric); + Assert.isInstanceOf(Map.class, mapListUserGeneric.value); + return mapListUserGeneric; + } +} diff --git a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/utils/ClassUtils.java b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/utils/ClassUtils.java index ae7b7ad..1e43c7e 100644 --- a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/utils/ClassUtils.java +++ b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/utils/ClassUtils.java @@ -166,7 +166,7 @@ public final class ClassUtils { continue; } - part = part.replaceAll("[;<>-]", "_").replace("[", "array_"); + part = part.replaceAll("[,;<>-]", "_").replace("[", "array_"); if (Character.isDigit(part.charAt(0)) || SourceVersion.isKeyword(part)) { part = "_" + part; }
