Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCB-2062] jaxrs mode support PATCH #1913

Merged
merged 1 commit into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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.
## ---------------------------------------------------------------------------

---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add license

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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"