jungan21 commented on a change in pull request #1766:
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1766#discussion_r428916191



##########
File path: 
service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/serviceregistry/SchemaContentEndpoint.java
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.serviceregistry;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+
+import org.apache.servicecomb.serviceregistry.client.ClientUtil;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import javax.ws.rs.core.MediaType;
+import java.util.Map;
+
+import static 
org.apache.servicecomb.serviceregistry.ZeroConfigRegistryConstants.*;
+
+@RestSchema(schemaId = SCHEMA_CONTENT_ENDPOINT)
+@RequestMapping(path = SCHEMA_CONTENT_ENDPOINT_BASE_PATH)

Review comment:
       I tried with pure JAX-RS annotation today It seems our swagger generator 
has issue for processing JAX-RS **@QueryParam** and **@PathParam**.  When there 
is no path parameter annotation, it's OK. Below please find the details.
   
   **1. Error when parsing JAX-RS @QueryParam annotation to take in query 
parameter. I 
   
   ```
   
   @RestSchema(schemaId = "schemaContentEndpoint")
   @Path("/schemaEndpoint")
   @Produces(MediaType.TEXT_PLAIN)
   public class SchemaContentEndpoint {
   
       @Path("/schemas")
       @GET
       public String getSchemaEndpoint(**@QueryParam**("schemaId") String 
schemaId) {
           Map<String, String> schemaMap = 
ClientUtil.microserviceSelf.getSchemaMap();
           return schemaMap.get(schemaId);
       }
   }
   ```
   
   **Error message:**
   ```
   Caused by: java.lang.IllegalStateException: parameter name is not present, 
method=org.apache.servicecomb.zeroconfigsc.SchemaContentEndpoint:getSchemaEndpoint
   solution:
     change pom.xml, add compiler argument: -parameters, for example:
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
           <compilerArgument>-parameters</compilerArgument>
         </configuration>
       </plugin>
        at 
org.apache.servicecomb.swagger.generator.SwaggerGeneratorUtils.collectParameterName(SwaggerGeneratorUtils.java:192)
        at 
org.apache.servicecomb.swagger.generator.ParameterGenerator.<init>(ParameterGenerator.java:55)
        at 
org.apache.servicecomb.swagger.generator.ParameterGenerator.<init>(ParameterGenerator.java:66)
        at 
org.apache.servicecomb.swagger.generator.core.AbstractOperationGenerator.initMethodParameterGenerators(AbstractOperationGenerator.java:230)
   ```
   
   BTW, if I replace @QueryParam with SpringMVC @RequestParameter, it works 
fine. Also If I remove @QueryParam, it works fine too.
   
   
   Based on the error message, it seems **name** attribute is required for 
swagger generator to be able to process/parse the Annotation. 
   `
   
   
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to