This is an automated email from the ASF dual-hosted git repository.

chanjarster pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-toolkit.git

commit fdbdafbf61715d822a5812bd67ca64ffbf3e30b8
Author: kakulisen <[email protected]>
AuthorDate: Mon Oct 28 10:17:35 2019 +0800

    add oas-generator-spring to support parse spring code
    
    Signed-off-by: kakulisen <[email protected]>
---
 oas-generator/{ => oas-generator-spring}/pom.xml   |  37 +---
 .../generator/MultipartFileInterceptor.java        |  44 ++++
 ...stractHttpMethodMappingAnnotationProcessor.java |  84 ++++++++
 .../DeleteMappingMethodAnnotationProcessor.java    |  35 ++++
 .../GetMappingMethodAnnotationProcessor.java       |  35 ++++
 .../PathVariableAnnotationProcessor.java           |  41 ++++
 .../PostMappingMethodAnnotationProcessor.java      |  35 ++++
 .../PutMappingMethodAnnotationProcessor.java       |  35 ++++
 .../annotation/RequestBodyAnnotationProcessor.java |  29 +++
 .../RequestHeaderAnnotationProcessor.java          |  47 +++++
 .../RequestMappingClassAnnotationProcessor.java    |  41 ++++
 .../RequestMappingMethodAnnotationProcessor.java   |  41 ++++
 .../RequestParamAnnotationProcessor.java           |  43 ++++
 .../annotation/RequestPartAnnotationProcessor.java |  28 +++
 .../parser/SpringmvcAnnotationParser.java          |  78 +++++++
 ...b.toolkit.generator.annotation.ModelInterceptor |  18 ++
 ...it.generator.parser.api.OpenApiAnnotationParser |  18 ++
 .../generator/SpringAnnotationProcessorTest.java   | 225 +++++++++++++++++++++
 .../toolkit/generator/SpringParserTest.java        |  45 +++++
 oas-generator/pom.xml                              |   1 +
 20 files changed, 930 insertions(+), 30 deletions(-)

diff --git a/oas-generator/pom.xml b/oas-generator/oas-generator-spring/pom.xml
similarity index 60%
copy from oas-generator/pom.xml
copy to oas-generator/oas-generator-spring/pom.xml
index dafeed5..c2d70f0 100644
--- a/oas-generator/pom.xml
+++ b/oas-generator/oas-generator-spring/pom.xml
@@ -19,47 +19,24 @@
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
   <parent>
-    <artifactId>toolkit</artifactId>
+    <artifactId>oas-generator</artifactId>
     <groupId>org.apache.servicecomb.toolkit</groupId>
     <version>0.2.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
-  <packaging>pom</packaging>
-  <modules>
-    <module>oas-generator-core</module>
-    <module>oas-generator-jaxrs</module>
-  </modules>
 
-  <artifactId>oas-generator</artifactId>
+  <artifactId>oas-generator-spring</artifactId>
 
   <dependencies>
     <dependency>
-      <groupId>org.powermock</groupId>
-      <artifactId>powermock-module-junit4</artifactId>
-      <version>1.6.2</version>
-      <scope>test</scope>
+      <groupId>org.apache.servicecomb.toolkit</groupId>
+      <artifactId>oas-generator-core</artifactId>
     </dependency>
-
     <dependency>
-      <groupId>org.powermock</groupId>
-      <artifactId>powermock-api-mockito</artifactId>
-      <version>1.6.2</version>
-      <scope>test</scope>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-web</artifactId>
+      <version>5.2.0.RELEASE</version>
     </dependency>
   </dependencies>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.8.1</version>
-        <configuration>
-          <target>1.8</target>
-          <source>1.8</source>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
 </project>
\ No newline at end of file
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/MultipartFileInterceptor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/MultipartFileInterceptor.java
new file mode 100644
index 0000000..4857143
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/MultipartFileInterceptor.java
@@ -0,0 +1,44 @@
+/*
+ * 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.toolkit.generator;
+
+import org.apache.servicecomb.toolkit.generator.annotation.ModelInterceptor;
+import org.apache.servicecomb.toolkit.generator.util.ModelConverter;
+import org.springframework.web.multipart.MultipartFile;
+
+import io.swagger.v3.oas.models.Components;
+import io.swagger.v3.oas.models.media.FileSchema;
+import io.swagger.v3.oas.models.media.Schema;
+
+public class MultipartFileInterceptor implements ModelInterceptor {
+
+  @Override
+  public int order() {
+    return 100;
+  }
+
+  @Override
+  public Schema process(Class<?> cls, Components components) {
+
+    if (!MultipartFile.class.equals(cls)) {
+      return null;
+    }
+
+    return new FileSchema();
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/AbstractHttpMethodMappingAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/AbstractHttpMethodMappingAnnotationProcessor.java
new file mode 100644
index 0000000..fe795ea
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/AbstractHttpMethodMappingAnnotationProcessor.java
@@ -0,0 +1,84 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.servicecomb.toolkit.generator.HttpStatus;
+import org.apache.servicecomb.toolkit.generator.OperationContext;
+import org.apache.servicecomb.toolkit.generator.util.ModelConverter;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import io.swagger.v3.oas.models.media.Content;
+import io.swagger.v3.oas.models.media.MediaType;
+import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.responses.ApiResponse;
+
+public abstract class AbstractHttpMethodMappingAnnotationProcessor<Annotation, 
Context> implements
+    MethodAnnotationProcessor<Annotation, Context> {
+
+  protected void processPath(String[] paths, OperationContext 
operationContext) {
+    if (null == paths || paths.length == 0) {
+      return;
+    }
+
+    if (paths.length > 1) {
+      throw new Error(String.format("not allowed multi path for %s:%s",
+          operationContext.getMethod().getDeclaringClass().getName(),
+          operationContext.getMethod().getName()));
+    }
+
+    operationContext.setPath(paths[0]);
+  }
+
+  protected void processMethod(RequestMethod requestMethod, OperationContext 
operationContext) {
+    operationContext.setHttpMethod(requestMethod.name());
+  }
+
+  protected void processConsumes(String[] consumes, OperationContext 
operationContext) {
+    if (null == consumes || consumes.length == 0) {
+      return;
+    }
+  }
+
+  protected void processProduces(String[] produces, OperationContext 
operationContext) {
+    if (null == produces || produces.length == 0) {
+      return;
+    }
+
+    List<String> produceList = Arrays.stream(produces).filter(s -> 
!StringUtils.isEmpty(s))
+        .collect(Collectors.toList());
+
+    if (!produceList.isEmpty()) {
+      ApiResponse apiResponse = new ApiResponse();
+      Content content = new Content();
+      MediaType mediaType = new MediaType();
+      Schema schema = ModelConverter
+          .getSchema(operationContext.getMethod().getReturnType(), 
operationContext.getComponents());
+      mediaType.schema(schema);
+      for (String produce : produceList) {
+        content.addMediaType(produce, mediaType);
+      }
+      apiResponse.setContent(content);
+      operationContext.addResponse(HttpStatus.OK, apiResponse);
+    }
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/DeleteMappingMethodAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/DeleteMappingMethodAnnotationProcessor.java
new file mode 100644
index 0000000..a53736f
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/DeleteMappingMethodAnnotationProcessor.java
@@ -0,0 +1,35 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.servicecomb.toolkit.generator.OperationContext;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+public class DeleteMappingMethodAnnotationProcessor extends
+    AbstractHttpMethodMappingAnnotationProcessor<DeleteMapping, 
OperationContext> {
+
+  @Override
+  public void process(DeleteMapping deleteMapping, OperationContext 
operationContext) {
+    processPath(deleteMapping.path(), operationContext);
+    processPath(deleteMapping.value(), operationContext);
+    processMethod(RequestMethod.DELETE, operationContext);
+    processConsumes(deleteMapping.consumes(), operationContext);
+    processProduces(deleteMapping.produces(), operationContext);
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/GetMappingMethodAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/GetMappingMethodAnnotationProcessor.java
new file mode 100644
index 0000000..7bbf769
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/GetMappingMethodAnnotationProcessor.java
@@ -0,0 +1,35 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.servicecomb.toolkit.generator.OperationContext;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+public class GetMappingMethodAnnotationProcessor extends 
AbstractHttpMethodMappingAnnotationProcessor<GetMapping, OperationContext> {
+
+  @Override
+  public void process(GetMapping getMapping, OperationContext 
operationContext) {
+    processPath(getMapping.path(), operationContext);
+    this.processPath(getMapping.path(), operationContext);
+    this.processPath(getMapping.value(), operationContext);
+    this.processMethod(RequestMethod.GET, operationContext);
+    this.processConsumes(getMapping.consumes(), operationContext);
+    this.processProduces(getMapping.produces(), operationContext);
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PathVariableAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PathVariableAnnotationProcessor.java
new file mode 100644
index 0000000..bc752f3
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PathVariableAnnotationProcessor.java
@@ -0,0 +1,41 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.servicecomb.toolkit.generator.ParameterContext;
+import org.apache.servicecomb.toolkit.generator.util.ParamUtils;
+import org.springframework.web.bind.annotation.PathVariable;
+
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
+
+public class PathVariableAnnotationProcessor implements 
ParamAnnotationProcessor<PathVariable, ParameterContext> {
+  @Override
+  public void process(PathVariable pathVariable, ParameterContext 
parameterContext) {
+
+    String paramName = pathVariable.name();
+    if (StringUtils.isEmpty(paramName)) {
+      paramName = ParamUtils
+          .getParamterName(parameterContext.getOperationContext().getMethod(), 
parameterContext.getParameter());
+    }
+
+    parameterContext.setName(paramName);
+    parameterContext.setRequired(pathVariable.required());
+    parameterContext.setType(ParameterIn.PATH.toString());
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PostMappingMethodAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PostMappingMethodAnnotationProcessor.java
new file mode 100644
index 0000000..9848cca
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PostMappingMethodAnnotationProcessor.java
@@ -0,0 +1,35 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.servicecomb.toolkit.generator.OperationContext;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+public class PostMappingMethodAnnotationProcessor extends 
AbstractHttpMethodMappingAnnotationProcessor<PostMapping, OperationContext> {
+
+  @Override
+  public void process(PostMapping postMapping, OperationContext 
operationContext) {
+
+    this.processPath(postMapping.path(), operationContext);
+    this.processPath(postMapping.value(), operationContext);
+    this.processMethod(RequestMethod.POST, operationContext);
+    this.processConsumes(postMapping.consumes(), operationContext);
+    this.processProduces(postMapping.produces(), operationContext);
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PutMappingMethodAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PutMappingMethodAnnotationProcessor.java
new file mode 100644
index 0000000..53f4738
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/PutMappingMethodAnnotationProcessor.java
@@ -0,0 +1,35 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.servicecomb.toolkit.generator.OperationContext;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+public class PutMappingMethodAnnotationProcessor extends 
AbstractHttpMethodMappingAnnotationProcessor<PutMapping, OperationContext> {
+
+  @Override
+  public void process(PutMapping putMapping, OperationContext 
operationContext) {
+
+    this.processPath(putMapping.path(), operationContext);
+    this.processPath(putMapping.value(), operationContext);
+    this.processMethod(RequestMethod.PUT, operationContext);
+    this.processConsumes(putMapping.consumes(), operationContext);
+    this.processProduces(putMapping.produces(), operationContext);
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestBodyAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestBodyAnnotationProcessor.java
new file mode 100644
index 0000000..2b0a114
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestBodyAnnotationProcessor.java
@@ -0,0 +1,29 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.servicecomb.toolkit.generator.ParameterContext;
+import org.springframework.web.bind.annotation.RequestBody;
+
+public class RequestBodyAnnotationProcessor implements 
ParamAnnotationProcessor<RequestBody, ParameterContext> {
+
+  @Override
+  public void process(RequestBody requestBody, ParameterContext 
parameterContext) {
+    parameterContext.setRequired(requestBody.required());
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestHeaderAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestHeaderAnnotationProcessor.java
new file mode 100644
index 0000000..ece07cc
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestHeaderAnnotationProcessor.java
@@ -0,0 +1,47 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.servicecomb.toolkit.generator.ParameterContext;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.ValueConstants;
+
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
+
+public class RequestHeaderAnnotationProcessor implements 
ParamAnnotationProcessor<RequestHeader, ParameterContext> {
+
+  @Override
+  public void process(RequestHeader requestHeader, ParameterContext 
parameterContext) {
+    parameterContext.setType(ParameterIn.HEADER.toString());
+    parameterContext.setRequired(requestHeader.required());
+
+    if (!ObjectUtils.isEmpty(requestHeader.defaultValue()) && 
!ValueConstants.DEFAULT_NONE
+        .equals(requestHeader.defaultValue())) {
+      parameterContext.setDefaultValue(requestHeader.defaultValue());
+    }
+
+    String name = requestHeader.name();
+    if (StringUtils.isEmpty(name)) {
+      name = requestHeader.value();
+    }
+
+    parameterContext.setName(name);
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestMappingClassAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestMappingClassAnnotationProcessor.java
new file mode 100644
index 0000000..a44bb0d
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestMappingClassAnnotationProcessor.java
@@ -0,0 +1,41 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.servicecomb.toolkit.generator.OasContext;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+public class RequestMappingClassAnnotationProcessor implements
+    ClassAnnotationProcessor<RequestMapping, OasContext> {
+
+  @Override
+  public void process(RequestMapping requestMapping, OasContext oasContext) {
+
+    String[] paths = requestMapping.value();
+    if (null == paths || paths.length == 0) {
+      return;
+    }
+
+    // swagger仅支持配一个basePath
+    if (paths.length > 1) {
+      throw new Error("not support multi path for " + 
oasContext.getCls().getName());
+    }
+
+    oasContext.setBasePath(paths[0]);
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestMappingMethodAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestMappingMethodAnnotationProcessor.java
new file mode 100644
index 0000000..bdcc3fc
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestMappingMethodAnnotationProcessor.java
@@ -0,0 +1,41 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.servicecomb.toolkit.generator.OperationContext;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+public class RequestMappingMethodAnnotationProcessor implements
+    MethodAnnotationProcessor<RequestMapping, OperationContext> {
+
+  @Override
+  public void process(RequestMapping requestMapping, OperationContext 
operationContext) {
+
+    String[] paths = requestMapping.value();
+    if (null == paths || paths.length == 0) {
+      return;
+    }
+
+    // swagger仅支持配一个basePath
+    if (paths.length > 1) {
+      throw new Error("not support multi path for " + 
operationContext.getMethod().getName());
+    }
+
+    operationContext.setPath(paths[0]);
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestParamAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestParamAnnotationProcessor.java
new file mode 100644
index 0000000..8a127c3
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestParamAnnotationProcessor.java
@@ -0,0 +1,43 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.servicecomb.toolkit.generator.ParameterContext;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ValueConstants;
+
+public class RequestParamAnnotationProcessor implements 
ParamAnnotationProcessor<RequestParam, ParameterContext> {
+
+  @Override
+  public void process(RequestParam requestParam, ParameterContext 
parameterContext) {
+    String name = requestParam.value();
+    if (StringUtils.isEmpty(name)) {
+      name = requestParam.name();
+    }
+
+    parameterContext.setName(name);
+    parameterContext.setRequired(requestParam.required());
+    if (!ObjectUtils.isEmpty(requestParam.defaultValue()) && 
!ValueConstants.DEFAULT_NONE
+        .equals(requestParam.defaultValue())) {
+      parameterContext.setDefaultValue(requestParam.defaultValue());
+      parameterContext.setRequired(false);
+    }
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestPartAnnotationProcessor.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestPartAnnotationProcessor.java
new file mode 100644
index 0000000..1fdcc55
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/annotation/RequestPartAnnotationProcessor.java
@@ -0,0 +1,28 @@
+/*
+ * 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.toolkit.generator.annotation;
+
+import org.apache.servicecomb.toolkit.generator.ParameterContext;
+import org.springframework.web.bind.annotation.RequestPart;
+
+public class RequestPartAnnotationProcessor implements 
ParamAnnotationProcessor<RequestPart, ParameterContext> {
+  @Override
+  public void process(RequestPart requestPart, ParameterContext 
parameterContext) {
+
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/parser/SpringmvcAnnotationParser.java
 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/parser/SpringmvcAnnotationParser.java
new file mode 100644
index 0000000..59a65c3
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/java/org/apache/servicecomb/toolkit/generator/parser/SpringmvcAnnotationParser.java
@@ -0,0 +1,78 @@
+/*
+ * 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.toolkit.generator.parser;
+
+import org.apache.servicecomb.toolkit.generator.OasContext;
+import 
org.apache.servicecomb.toolkit.generator.annotation.GetMappingMethodAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.PathVariableAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.PostMappingMethodAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.PutMappingMethodAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.RequestBodyAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.RequestMappingClassAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.RequestMappingMethodAnnotationProcessor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+public class SpringmvcAnnotationParser extends AbstractAnnotationParser {
+
+  @Override
+  public int getOrder() {
+    return 0;
+  }
+
+  @Override
+  public void parser(Class<?> cls, OasContext context) {
+    super.parser(cls, context);
+  }
+
+  @Override
+  public boolean canProcess(Class<?> cls) {
+    if (cls.getAnnotation(RestController.class) != null) {
+      return true;
+    }
+    return false;
+  }
+
+  @Override
+  public void initClassAnnotationProcessor() {
+    super.initClassAnnotationProcessor();
+    classAnnotationMap.put(RequestMapping.class, new 
RequestMappingClassAnnotationProcessor());
+  }
+
+  @Override
+  public void initMethodAnnotationProcessor() {
+    super.initMethodAnnotationProcessor();
+    methodAnnotationMap.put(RequestMapping.class, new 
RequestMappingMethodAnnotationProcessor());
+    methodAnnotationMap.put(GetMapping.class, new 
GetMappingMethodAnnotationProcessor());
+    methodAnnotationMap.put(PutMapping.class, new 
PutMappingMethodAnnotationProcessor());
+    methodAnnotationMap.put(PostMapping.class, new 
PostMappingMethodAnnotationProcessor());
+  }
+
+  @Override
+  public void initParameterAnnotationProcessor() {
+    super.initParameterAnnotationProcessor();
+    parameterAnnotationMap.put(PathVariable.class, new 
PathVariableAnnotationProcessor());
+    parameterAnnotationMap.put(RequestBody.class, new 
RequestBodyAnnotationProcessor());
+  }
+}
+
diff --git 
a/oas-generator/oas-generator-spring/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.annotation.ModelInterceptor
 
b/oas-generator/oas-generator-spring/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.annotation.ModelInterceptor
new file mode 100644
index 0000000..50c3a84
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.annotation.ModelInterceptor
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.servicecomb.toolkit.generator.MultipartFileInterceptor
\ No newline at end of file
diff --git 
a/oas-generator/oas-generator-spring/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser
 
b/oas-generator/oas-generator-spring/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser
new file mode 100644
index 0000000..7d4e564
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.generator.parser.api.OpenApiAnnotationParser
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.servicecomb.toolkit.generator.parser.SpringmvcAnnotationParser
\ No newline at end of file
diff --git 
a/oas-generator/oas-generator-spring/src/test/java/org/apache/servicecomb/toolkit/generator/SpringAnnotationProcessorTest.java
 
b/oas-generator/oas-generator-spring/src/test/java/org/apache/servicecomb/toolkit/generator/SpringAnnotationProcessorTest.java
new file mode 100644
index 0000000..0bf7191
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/test/java/org/apache/servicecomb/toolkit/generator/SpringAnnotationProcessorTest.java
@@ -0,0 +1,225 @@
+/*
+ * 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.toolkit.generator;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+
+import 
org.apache.servicecomb.toolkit.generator.annotation.DeleteMappingMethodAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.GetMappingMethodAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.PathVariableAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.PostMappingMethodAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.PutMappingMethodAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.RequestBodyAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.RequestHeaderAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.RequestMappingClassAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.RequestMappingMethodAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.RequestParamAnnotationProcessor;
+import 
org.apache.servicecomb.toolkit.generator.annotation.RequestPartAnnotationProcessor;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import io.swagger.v3.oas.models.media.FileSchema;
+
+public class SpringAnnotationProcessorTest {
+
+  @Test
+  public void getHttpMethod() throws NoSuchMethodException {
+
+    OasContext oasContext = new OasContext(null);
+    Class<HttpMethodResource> httpMethodResourceClass = 
HttpMethodResource.class;
+    RequestMapping requestMappingClassAnnotation = 
httpMethodResourceClass.getAnnotation(RequestMapping.class);
+    RequestMappingClassAnnotationProcessor 
requestMappingClassAnnotationProcessor = new 
RequestMappingClassAnnotationProcessor();
+    
requestMappingClassAnnotationProcessor.process(requestMappingClassAnnotation, 
oasContext);
+    Assert.assertEquals(requestMappingClassAnnotation.value()[0], 
oasContext.getBasePath());
+
+    RequestMappingMethodAnnotationProcessor 
requestMappingMethodAnnotationProcessor = new 
RequestMappingMethodAnnotationProcessor();
+    Method requestMethod = httpMethodResourceClass.getMethod("request");
+    RequestMapping requestMappingMethodAnnotation = 
requestMethod.getAnnotation(RequestMapping.class);
+    OperationContext requestOperationContext = new 
OperationContext(requestMethod, oasContext);
+    
requestMappingMethodAnnotationProcessor.process(requestMappingMethodAnnotation, 
requestOperationContext);
+    Assert
+        .assertEquals(requestMappingMethodAnnotation.value()[0],
+            requestOperationContext.getPath());
+
+    GetMappingMethodAnnotationProcessor getMappingMethodAnnotationProcessor = 
new GetMappingMethodAnnotationProcessor();
+    Method getMethod = httpMethodResourceClass.getMethod("get");
+    GetMapping getMappingAnnotation = 
getMethod.getAnnotation(GetMapping.class);
+    OperationContext getOperationContext = new OperationContext(getMethod, 
oasContext);
+    getMappingMethodAnnotationProcessor.process(getMappingAnnotation, 
getOperationContext);
+    Assert
+        .assertEquals(getMappingAnnotation.value()[0], 
getOperationContext.getPath());
+
+    PostMappingMethodAnnotationProcessor postMappingMethodAnnotationProcessor 
= new PostMappingMethodAnnotationProcessor();
+    Method postMethod = httpMethodResourceClass.getMethod("post");
+    PostMapping postMappingAnnotation = 
postMethod.getAnnotation(PostMapping.class);
+    OperationContext postOperationContext = new OperationContext(postMethod, 
oasContext);
+    postMappingMethodAnnotationProcessor.process(postMappingAnnotation, 
postOperationContext);
+    Assert
+        .assertEquals(postMappingAnnotation.value()[0], 
postOperationContext.getPath());
+
+    PutMappingMethodAnnotationProcessor putMappingMethodAnnotationProcessor = 
new PutMappingMethodAnnotationProcessor();
+    Method putMethod = httpMethodResourceClass.getMethod("put");
+    PutMapping putMappingAnnotation = 
putMethod.getAnnotation(PutMapping.class);
+    OperationContext putOperationContext = new OperationContext(putMethod, 
oasContext);
+    putMappingMethodAnnotationProcessor.process(putMappingAnnotation, 
putOperationContext);
+    Assert
+        .assertEquals(putMappingAnnotation.value()[0], 
putOperationContext.getPath());
+
+    DeleteMappingMethodAnnotationProcessor 
deleteMappingMethodAnnotationProcessor = new 
DeleteMappingMethodAnnotationProcessor();
+    Method deleteMethod = httpMethodResourceClass.getMethod("delete");
+    DeleteMapping delelteMappingAnnotation = 
deleteMethod.getAnnotation(DeleteMapping.class);
+    OperationContext deleteOperationContext = new 
OperationContext(deleteMethod, oasContext);
+    deleteMappingMethodAnnotationProcessor.process(delelteMappingAnnotation, 
deleteOperationContext);
+    Assert
+        .assertEquals(delelteMappingAnnotation.value()[0], 
deleteOperationContext.getPath());
+  }
+
+  @Test
+  public void parseParameter() throws NoSuchMethodException {
+    Class<ParamAnnotationResource> paramAnnotationResourceClass = 
ParamAnnotationResource.class;
+    OasContext oasContext = new OasContext(null);
+    OperationContext operationContext;
+    ParameterContext parameterContext;
+
+    RequestParamAnnotationProcessor requestParamAnnotationProcessor = new 
RequestParamAnnotationProcessor();
+    Method requestParamMethod = 
paramAnnotationResourceClass.getMethod("requestParam", String.class);
+    Parameter requestParamMethodParam = requestParamMethod.getParameters()[0];
+    RequestParam requestParamAnnotation = requestParamMethodParam
+        .getAnnotation(RequestParam.class);
+    operationContext = new OperationContext(requestParamMethod, oasContext);
+    parameterContext = new ParameterContext(operationContext, 
requestParamMethodParam);
+    requestParamAnnotationProcessor.process(requestParamAnnotation, 
parameterContext);
+    io.swagger.v3.oas.models.parameters.Parameter oasParameter = 
parameterContext.toOasParameter();
+    Assert.assertNull(parameterContext.getDefaultValue());
+    Assert.assertNull(oasParameter.getSchema().getDefault());
+
+    PathVariableAnnotationProcessor pathVariableAnnotationProcessor = new 
PathVariableAnnotationProcessor();
+    Method pathVariableMethod = 
paramAnnotationResourceClass.getMethod("pathVariable", String.class);
+    Parameter pathVariableMethodParam = pathVariableMethod.getParameters()[0];
+    PathVariable pathVariableAnnotation = pathVariableMethodParam
+        .getAnnotation(PathVariable.class);
+    operationContext = new OperationContext(pathVariableMethod, oasContext);
+    parameterContext = new ParameterContext(operationContext, 
pathVariableMethodParam);
+    pathVariableAnnotationProcessor.process(pathVariableAnnotation, 
parameterContext);
+    parameterContext.toOasParameter();
+    Assert.assertTrue(parameterContext.isRequired());
+
+    RequestPartAnnotationProcessor requestPartAnnotationProcessor = new 
RequestPartAnnotationProcessor();
+    Method requestPartMethod = 
paramAnnotationResourceClass.getMethod("requestPart", MultipartFile.class);
+    Parameter requestPartMethodParam = requestPartMethod.getParameters()[0];
+    RequestPart requestPartParamAnnotation = requestPartMethodParam
+        .getAnnotation(RequestPart.class);
+    operationContext = new OperationContext(requestPartMethod, oasContext);
+    parameterContext = new ParameterContext(operationContext, 
requestPartMethodParam);
+    requestPartAnnotationProcessor.process(requestPartParamAnnotation, 
parameterContext);
+    oasParameter = parameterContext.toOasParameter();
+    Assert.assertNull(parameterContext.getDefaultValue());
+    Assert.assertEquals(FileSchema.class, oasParameter.getSchema().getClass());
+
+    RequestHeaderAnnotationProcessor requestHeaderAnnotationProcessor = new 
RequestHeaderAnnotationProcessor();
+    Method requestHeaderMethod = 
paramAnnotationResourceClass.getMethod("requestHeader", String.class);
+    Parameter requestHeaderMethodParam = 
requestHeaderMethod.getParameters()[0];
+    RequestHeader requestHeaderParamAnnotation = requestHeaderMethodParam
+        .getAnnotation(RequestHeader.class);
+    operationContext = new OperationContext(requestPartMethod, oasContext);
+    parameterContext = new ParameterContext(operationContext, 
requestHeaderMethodParam);
+    requestHeaderAnnotationProcessor.process(requestHeaderParamAnnotation, 
parameterContext);
+    oasParameter = parameterContext.toOasParameter();
+    Assert.assertNull(parameterContext.getDefaultValue());
+    Assert.assertNull(oasParameter.getSchema().getDefault());
+
+    RequestBodyAnnotationProcessor requestBodyAnnotationProcessor = new 
RequestBodyAnnotationProcessor();
+    Method requestBodyMethod = 
paramAnnotationResourceClass.getMethod("requestBody", String.class);
+    Parameter requestBodyMethodParam = requestBodyMethod.getParameters()[0];
+    RequestBody requestBodyParamAnnotation = requestBodyMethodParam
+        .getAnnotation(RequestBody.class);
+    operationContext = new OperationContext(requestBodyMethod, oasContext);
+    parameterContext = new ParameterContext(operationContext, 
requestBodyMethodParam);
+    requestBodyAnnotationProcessor.process(requestBodyParamAnnotation, 
parameterContext);
+    parameterContext.toOasParameter();
+    Assert.assertTrue(parameterContext.isRequired());
+  }
+
+  @Test
+  public void interceptorModel() {
+    MultipartFileInterceptor interceptor = new MultipartFileInterceptor();
+    Assert.assertEquals(100, interceptor.order());
+  }
+
+  @RestController
+  @RequestMapping("/path")
+  class HttpMethodResource {
+
+    @RequestMapping("/request")
+    public String request() {
+      return "request";
+    }
+
+    @GetMapping(value = "/get", consumes = {"application/json"})
+    public String get() {
+      return "get";
+    }
+
+    @PostMapping("/post")
+    public String post() {
+      return "post";
+    }
+
+    @PutMapping("/put")
+    public String put() {
+      return "put";
+    }
+
+    @DeleteMapping("/delete")
+    public String delete() {
+      return "delete";
+    }
+  }
+
+
+  class ParamAnnotationResource {
+
+    public void requestParam(@RequestParam("param") String param) {
+    }
+
+    public void requestBody(@RequestBody String param) {
+    }
+
+    public void requestHeader(@RequestHeader String headerParam) {
+    }
+
+    public void requestPart(@RequestPart MultipartFile file) {
+    }
+
+    public void pathVariable(@PathVariable String path) {
+    }
+  }
+}
diff --git 
a/oas-generator/oas-generator-spring/src/test/java/org/apache/servicecomb/toolkit/generator/SpringParserTest.java
 
b/oas-generator/oas-generator-spring/src/test/java/org/apache/servicecomb/toolkit/generator/SpringParserTest.java
new file mode 100644
index 0000000..fd8dfb2
--- /dev/null
+++ 
b/oas-generator/oas-generator-spring/src/test/java/org/apache/servicecomb/toolkit/generator/SpringParserTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.toolkit.generator;
+
+import 
org.apache.servicecomb.toolkit.generator.parser.SpringmvcAnnotationParser;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.web.bind.annotation.RestController;
+
+public class SpringParserTest {
+
+  @Test
+  public void parse() {
+    SpringmvcAnnotationParser parser = new SpringmvcAnnotationParser();
+
+    boolean canProcess = parser.canProcess(String.class);
+    Assert.assertFalse(canProcess);
+
+    canProcess = parser.canProcess(SpringmvcController.class);
+    Assert.assertTrue(canProcess);
+
+    OasContext oasContext = new OasContext(parser);
+    parser.parser(SpringmvcController.class, oasContext);
+  }
+
+  @RestController
+  class SpringmvcController {
+
+  }
+}
diff --git a/oas-generator/pom.xml b/oas-generator/pom.xml
index dafeed5..849e520 100644
--- a/oas-generator/pom.xml
+++ b/oas-generator/pom.xml
@@ -28,6 +28,7 @@
   <modules>
     <module>oas-generator-core</module>
     <module>oas-generator-jaxrs</module>
+    <module>oas-generator-spring</module>
   </modules>
 
   <artifactId>oas-generator</artifactId>

Reply via email to