Skip to content

Commit

Permalink
[SCB-2062] jaxrs mode support PATCH
Browse files Browse the repository at this point in the history
  • Loading branch information
wujimin committed Aug 10, 2020
1 parent 0f931ba commit 3ec7b9d
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
@@ -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.swagger.generator.jaxrs.processor.annotation;

import java.lang.reflect.Type;

import javax.ws.rs.PATCH;

public class PatchAnnotationProcessor extends GetAnnotationProcessor {
@Override
public Type getProcessType() {
return PATCH.class;
}
}
Expand Up @@ -21,4 +21,5 @@ org.apache.servicecomb.swagger.generator.jaxrs.processor.annotation.PathMethodAn
org.apache.servicecomb.swagger.generator.jaxrs.processor.annotation.GetAnnotationProcessor
org.apache.servicecomb.swagger.generator.jaxrs.processor.annotation.PostAnnotationProcessor
org.apache.servicecomb.swagger.generator.jaxrs.processor.annotation.PutAnnotationProcessor
org.apache.servicecomb.swagger.generator.jaxrs.processor.annotation.DeleteAnnotationProcessor
org.apache.servicecomb.swagger.generator.jaxrs.processor.annotation.DeleteAnnotationProcessor
org.apache.servicecomb.swagger.generator.jaxrs.processor.annotation.PatchAnnotationProcessor
Expand Up @@ -25,6 +25,7 @@
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.PATCH;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
Expand All @@ -49,6 +50,11 @@

@Path(value = "Echo")
public class Echo {
@PATCH
public void patch() {

}

@POST
@ApiResponse(response = int.class, code = 200, message = "")
public Response response() {
Expand Down
Expand Up @@ -138,6 +138,11 @@ public void nestedListString() {
UnitTestSwaggerUtils.testSwagger("schemas/nestedListString.yaml", Echo.class, "nestedListString");
}

@Test
public void should_support_patch_http_method() {
UnitTestSwaggerUtils.testSwagger("schemas/patch.yaml", Echo.class, "patch");
}

@Test
public void beanParamComplexField() {
UnitTestSwaggerUtils.testException(
Expand All @@ -159,7 +164,6 @@ public void beanParamComplexSetter() {
}

@Test

public void beanParamInvalidDefaultBody() {
UnitTestSwaggerUtils.testException(
"generate swagger operation failed, method=org.apache.servicecomb.swagger.generator.jaxrs.Echo:beanParamInvalidDefaultBody.",
Expand Down
@@ -0,0 +1,36 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------

---
swagger: "2.0"
info:
version: "1.0.0"
title: "swagger definition for org.apache.servicecomb.swagger.generator.jaxrs.Echo"
x-java-interface: "gen.cse.ms.ut.EchoIntf"
basePath: "/Echo"
consumes:
- "application/json"
produces:
- "application/json"
paths:
/:
patch:
operationId: "patch"
parameters: []
responses:
"200":
description: "response of 200"

0 comments on commit 3ec7b9d

Please sign in to comment.