This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git
commit 28f074310751a4363b05e60a17dfcb71c7cf7241 Author: wujimin <[email protected]> AuthorDate: Thu Dec 14 08:41:53 2017 +0800 JAV-548 producer support Part to be input parameter --- .../swagger/extend/ModelResolverExt.java | 2 ++ .../property/creator/PartPropertyCreator.java | 37 +++++++++++++++++++ .../property/creator/TestPartPropertyCreator.java | 42 ++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/extend/ModelResolverExt.java b/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/extend/ModelResolverExt.java index 3dfb227..0044a8d 100644 --- a/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/extend/ModelResolverExt.java +++ b/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/extend/ModelResolverExt.java @@ -35,6 +35,7 @@ import io.servicecomb.swagger.converter.property.StringPropertyConverter; import io.servicecomb.swagger.extend.property.creator.ByteArrayPropertyCreator; import io.servicecomb.swagger.extend.property.creator.BytePropertyCreator; import io.servicecomb.swagger.extend.property.creator.InputStreamPropertyCreator; +import io.servicecomb.swagger.extend.property.creator.PartPropertyCreator; import io.servicecomb.swagger.extend.property.creator.PropertyCreator; import io.servicecomb.swagger.extend.property.creator.ShortPropertyCreator; import io.swagger.converter.ModelConverter; @@ -58,6 +59,7 @@ public class ModelResolverExt extends ModelResolver { addPropertyCreator(new ShortPropertyCreator()); addPropertyCreator(new ByteArrayPropertyCreator()); addPropertyCreator(new InputStreamPropertyCreator()); + addPropertyCreator(new PartPropertyCreator()); loadPropertyCreators(); } diff --git a/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/extend/property/creator/PartPropertyCreator.java b/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/extend/property/creator/PartPropertyCreator.java new file mode 100644 index 0000000..7d8fb20 --- /dev/null +++ b/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/extend/property/creator/PartPropertyCreator.java @@ -0,0 +1,37 @@ +/* + * 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 io.servicecomb.swagger.extend.property.creator; + +import javax.servlet.http.Part; + +import io.swagger.models.properties.FileProperty; +import io.swagger.models.properties.Property; + +public class PartPropertyCreator implements PropertyCreator { + private final Class<?>[] classes = {Part.class}; + + @Override + public Property createProperty() { + return new FileProperty(); + } + + @Override + public Class<?>[] classes() { + return classes; + } +} diff --git a/swagger/swagger-generator/generator-core/src/test/java/io/servicecomb/swagger/extend/property/creator/TestPartPropertyCreator.java b/swagger/swagger-generator/generator-core/src/test/java/io/servicecomb/swagger/extend/property/creator/TestPartPropertyCreator.java new file mode 100644 index 0000000..4e8c8e5 --- /dev/null +++ b/swagger/swagger-generator/generator-core/src/test/java/io/servicecomb/swagger/extend/property/creator/TestPartPropertyCreator.java @@ -0,0 +1,42 @@ +/* + * 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 io.servicecomb.swagger.extend.property.creator; + +import javax.servlet.http.Part; + +import org.hamcrest.Matchers; +import org.junit.Assert; +import org.junit.Test; + +import io.swagger.models.properties.FileProperty; + + +public class TestPartPropertyCreator { + PartPropertyCreator creator = new PartPropertyCreator(); + + @SuppressWarnings("unchecked") + @Test + public void classes() { + Assert.assertThat(creator.classes(), Matchers.arrayContaining(Part.class)); + } + + @Test + public void createProperty() { + Assert.assertThat(creator.createProperty(), Matchers.instanceOf(FileProperty.class)); + } +} -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
