cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [16/17] cxf git commit: CXF-6046: Enhance SwaggerFeature to support JAX-RS annotations. Added more examples into demo.
Date Thu, 09 Jul 2015 09:05:11 GMT
CXF-6046: Enhance SwaggerFeature to support JAX-RS annotations. Added more examples into demo.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/514dfeaa
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/514dfeaa
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/514dfeaa

Branch: refs/heads/3.0.x-fixes
Commit: 514dfeaa75577cef74dbd41f001a3d0cb4ed4bfe
Parents: 58674d7
Author: reta <drreta@gmail.com>
Authored: Thu Jan 15 21:15:07 2015 -0500
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Thu Jul 9 11:02:12 2015 +0200

----------------------------------------------------------------------
 .../java/demo/jaxrs/swagger/server/Sample.java  | 36 ++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/514dfeaa/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Sample.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Sample.java
b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Sample.java
index ca92e7c..545d804 100644
--- a/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Sample.java
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Sample.java
@@ -21,16 +21,22 @@ package demo.jaxrs.swagger.server;
 
 import java.util.Arrays;
 
+import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.DefaultValue;
+import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import com.wordnik.swagger.annotations.Api;
 import com.wordnik.swagger.annotations.ApiImplicitParam;
@@ -73,6 +79,36 @@ public class Sample {
         return new Item("name", "Value in " + language);
     }
     
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @POST
+    @ApiOperation(
+        value = "Post operation with entity in a body", 
+        notes = "Post operation with entity in a body",
+        response = Item.class
+    )
+    public Response createItem(
+        @Context final UriInfo uriInfo,
+        @ApiParam(value = "item", required = true) final Item item) {
+        
+        return Response
+            .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
+            .entity(item).build();
+    }
+    
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Path("/{name}")
+    @PUT
+    @ApiOperation(
+        value = "Put operation with form parameter", 
+        notes = "Put operation with form parameter",
+        response = Item.class
+    )
+    public Item updateItem(
+        @ApiParam(value = "name", required = true) @PathParam("name") String name,
+        @ApiParam(value = "value", required = true) @FormParam("value") String value) { 
      
+        return new Item(name, value);
+    }
+    
     @Path("/{name}")
     @DELETE
     @ApiOperation(


Mime
View raw message