cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/2] cxf git commit: CXF-6046: Enhance SwaggerFeature to support JAX-RS annotations. Added more examples into demo.
Date Fri, 16 Jan 2015 02:18:19 GMT
Repository: cxf
Updated Branches:
  refs/heads/master a2e1e40d3 -> 7d3944d6e


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/8fd8c552
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8fd8c552
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8fd8c552

Branch: refs/heads/master
Commit: 8fd8c552f4c2a980a5138de19a2b74104776a4ba
Parents: 85ebf3f
Author: reta <drreta@gmail.com>
Authored: Thu Jan 15 21:15:07 2015 -0500
Committer: reta <drreta@gmail.com>
Committed: Thu Jan 15 21:16:01 2015 -0500

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/8fd8c552/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