[
https://issues.apache.org/jira/browse/SCB-708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16547547#comment-16547547
]
ASF GitHub Bot commented on SCB-708:
------------------------------------
yhs0092 commented on a change in pull request #815: [SCB-708] Aggregate simple
query params into object param in spring mvc style
URL:
https://github.com/apache/incubator-servicecomb-java-chassis/pull/815#discussion_r203294554
##########
File path:
swagger/swagger-generator/generator-springmvc/src/main/java/org/apache/servicecomb/swagger/generator/springmvc/processor/parameter/SpringmvcDefaultObjectParameterProcessor.java
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.swagger.generator.springmvc.processor.parameter;
+
+import java.lang.reflect.Type;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.servicecomb.swagger.generator.core.DefaultParameterProcessor;
+import org.apache.servicecomb.swagger.generator.core.OperationGenerator;
+import org.apache.servicecomb.swagger.generator.core.utils.ParamUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.swagger.converter.ModelConverters;
+import io.swagger.models.Model;
+import io.swagger.models.parameters.AbstractSerializableParameter;
+import io.swagger.models.parameters.QueryParameter;
+import io.swagger.models.properties.Property;
+import io.swagger.models.properties.RefProperty;
+
+/**
+ * Flatten a object parameter into a set of flatten simple parameters.
+ * <p/>
+ * <em>Nesting object params and generic Object params are NOT supported.</em>
+ * We support query object just for aggregating query params instead of
transporting objects in query param.
+ * So we don't support a generic param whose generic type is complex, but a
simple generic type param can be supported.
+ */
+public class SpringmvcDefaultObjectParameterProcessor implements
DefaultParameterProcessor {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(SpringmvcDefaultObjectParameterProcessor.class);
+
+ @Override
+ public void process(OperationGenerator operationGenerator, int paramIndex) {
+ Model paramModel = getParamModel(operationGenerator, paramIndex);
+
+ if (null == paramModel) {
+ LOGGER.warn("cannot find param, provider method is [{}], paramIndex =
[{}]",
Review comment:
Fixed, now an error will be thrown to interrupt boot up procedure
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Support assembling query param into Object parameter(in Spring MVC developing
> style)
> ------------------------------------------------------------------------------------
>
> Key: SCB-708
> URL: https://issues.apache.org/jira/browse/SCB-708
> Project: Apache ServiceComb
> Issue Type: New Feature
> Reporter: YaoHaishi
> Assignee: YaoHaishi
> Priority: Major
> Fix For: java-chassis-1.1.0
>
>
> In Spring Boot, user can define a REST operation with Object parameters, and
> there is no Annotation on the param like below:
> {code:java}
> @RequestMapping("/address")
> public String address(Address address)
> {code}
> {code:java}
> public class Address {
> String country;
> String city;
> }
> {code}
> Spring can assemble the query variable city and country into address, like
> /address?city=cc&country=co
> We need to support similar function.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)