cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject cxf git commit: make the swagger samples respond to reflect its changed states
Date Mon, 17 Aug 2015 15:26:51 GMT
Repository: cxf
Updated Branches:
  refs/heads/master d1b812ee9 -> f37119381


make the swagger samples respond to reflect its changed states


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

Branch: refs/heads/master
Commit: f37119381a834019ad15a63fcef2d86e8af96439
Parents: d1b812e
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Mon Aug 17 17:22:07 2015 +0200
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Mon Aug 17 17:22:23 2015 +0200

----------------------------------------------------------------------
 .../java/demo/jaxrs/swagger/server/Sample.java  | 28 ++++++++++++------
 .../java/demo/jaxrs/swagger/server/Sample.java  | 31 +++++++++++++-------
 .../java/demo/jaxrs/swagger/server/Sample.java  | 31 +++++++++++++-------
 .../java/demo/jaxrs/swagger/server/Sample.java  | 31 +++++++++++++-------
 4 files changed, 82 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f3711938/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 545d804..7b83508 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
@@ -20,6 +20,9 @@
 package demo.jaxrs.swagger.server;
 
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -47,6 +50,15 @@ import com.wordnik.swagger.annotations.ApiParam;
 @Path("/sample") 
 @Api(value = "/sample", description = "Sample JAX-RS service with Swagger documentation")
 public class Sample {
+    private Map<String, Item> items;
+
+    public Sample() {
+        items = Collections.synchronizedMap(new TreeMap<String, Item>(String.CASE_INSENSITIVE_ORDER));
+        items.put("Item 1", new Item("Item 1", "Value 1"));
+        items.put("Item 2", new Item("Item 2", "Value 2"));
+    }
+
+
     @Produces({ MediaType.APPLICATION_JSON })
     @GET
     @ApiOperation(
@@ -57,12 +69,7 @@ public class Sample {
     )
     public Response getItems(
         @ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1")
int page) {
-        return Response.ok(
-            Arrays.asList(
-                new Item("Item 1", "Value 1"),
-                new Item("Item 2", "Value 2")
-            )
-        ).build();
+        return Response.ok(items.values()).build();
     }
     
     @Produces({ MediaType.APPLICATION_JSON })
@@ -76,7 +83,7 @@ public class Sample {
     public Item getItem(
         @ApiParam(value = "language", required = true) @HeaderParam("Accept-Language") final
String language,
         @ApiParam(value = "name", required = true) @PathParam("name") String name) {
-        return new Item("name", "Value in " + language);
+        return items.get(name);
     }
     
     @Consumes({ MediaType.APPLICATION_JSON })
@@ -89,7 +96,7 @@ public class Sample {
     public Response createItem(
         @Context final UriInfo uriInfo,
         @ApiParam(value = "item", required = true) final Item item) {
-        
+        items.put(item.getName(), item);        
         return Response
             .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
             .entity(item).build();
@@ -106,7 +113,9 @@ public class Sample {
     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);
+        Item item = new Item(name, value);
+        items.put(name,  item);
+        return item;
     }
     
     @Path("/{name}")
@@ -125,6 +134,7 @@ public class Sample {
        )
     )
     public Response delete(@ApiParam(value = "name", required = true) @PathParam("name")
String name) {
+        items.remove(name);
         return Response.ok().build();
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/f3711938/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Sample.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Sample.java
b/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Sample.java
index 56d3213..4080348 100644
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Sample.java
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Sample.java
@@ -20,6 +20,9 @@
 package demo.jaxrs.swagger.server;
 
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -47,6 +50,15 @@ import io.swagger.annotations.ApiParam;
 @Path("/sample") 
 @Api(value = "/sample", description = "Sample JAX-RS service with Swagger documentation")
 public class Sample {
+    private Map<String, Item> items;
+
+    public Sample() {
+        items = Collections.synchronizedMap(new TreeMap<String, Item>(String.CASE_INSENSITIVE_ORDER));
+        items.put("Item 1", new Item("Item 1", "Value 1"));
+        items.put("Item 2", new Item("Item 2", "Value 2"));
+    }
+        
+    
     @Produces({ MediaType.APPLICATION_JSON })
     @GET
     @ApiOperation(
@@ -57,12 +69,8 @@ public class Sample {
     )
     public Response getItems(
         @ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1")
int page) {
-        return Response.ok(
-            Arrays.asList(
-                new Item("Item 1", "Value 1"),
-                new Item("Item 2", "Value 2")
-            )
-        ).build();
+
+        return Response.ok(items.values()).build();
     }
     
     @Produces({ MediaType.APPLICATION_JSON })
@@ -76,7 +84,7 @@ public class Sample {
     public Item getItem(
         @ApiParam(value = "language", required = true) @HeaderParam("Accept-Language") final
String language,
         @ApiParam(value = "name", required = true) @PathParam("name") String name) {
-        return new Item("name", "Value in " + language);
+        return items.get(name);
     }
     
     @Consumes({ MediaType.APPLICATION_JSON })
@@ -89,7 +97,7 @@ public class Sample {
     public Response createItem(
         @Context final UriInfo uriInfo,
         @ApiParam(value = "item", required = true) final Item item) {
-        
+        items.put(item.getName(), item);
         return Response
             .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
             .entity(item).build();
@@ -105,8 +113,10 @@ public class Sample {
     )
     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);
+        @ApiParam(value = "value", required = true) @FormParam("value") String value) {
+        Item item = new Item(name, value);
+        items.put(name,  item);
+        return item;
     }
     
     @Path("/{name}")
@@ -125,6 +135,7 @@ public class Sample {
        )
     )
     public Response delete(@ApiParam(value = "name", required = true) @PathParam("name")
String name) {
+        items.remove(name);
         return Response.ok().build();
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/f3711938/distribution/src/main/release/samples/jax_rs/description_swagger2_osgi/src/main/java/demo/jaxrs/swagger/server/Sample.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_osgi/src/main/java/demo/jaxrs/swagger/server/Sample.java
b/distribution/src/main/release/samples/jax_rs/description_swagger2_osgi/src/main/java/demo/jaxrs/swagger/server/Sample.java
index 56d3213..4080348 100644
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_osgi/src/main/java/demo/jaxrs/swagger/server/Sample.java
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger2_osgi/src/main/java/demo/jaxrs/swagger/server/Sample.java
@@ -20,6 +20,9 @@
 package demo.jaxrs.swagger.server;
 
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -47,6 +50,15 @@ import io.swagger.annotations.ApiParam;
 @Path("/sample") 
 @Api(value = "/sample", description = "Sample JAX-RS service with Swagger documentation")
 public class Sample {
+    private Map<String, Item> items;
+
+    public Sample() {
+        items = Collections.synchronizedMap(new TreeMap<String, Item>(String.CASE_INSENSITIVE_ORDER));
+        items.put("Item 1", new Item("Item 1", "Value 1"));
+        items.put("Item 2", new Item("Item 2", "Value 2"));
+    }
+        
+    
     @Produces({ MediaType.APPLICATION_JSON })
     @GET
     @ApiOperation(
@@ -57,12 +69,8 @@ public class Sample {
     )
     public Response getItems(
         @ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1")
int page) {
-        return Response.ok(
-            Arrays.asList(
-                new Item("Item 1", "Value 1"),
-                new Item("Item 2", "Value 2")
-            )
-        ).build();
+
+        return Response.ok(items.values()).build();
     }
     
     @Produces({ MediaType.APPLICATION_JSON })
@@ -76,7 +84,7 @@ public class Sample {
     public Item getItem(
         @ApiParam(value = "language", required = true) @HeaderParam("Accept-Language") final
String language,
         @ApiParam(value = "name", required = true) @PathParam("name") String name) {
-        return new Item("name", "Value in " + language);
+        return items.get(name);
     }
     
     @Consumes({ MediaType.APPLICATION_JSON })
@@ -89,7 +97,7 @@ public class Sample {
     public Response createItem(
         @Context final UriInfo uriInfo,
         @ApiParam(value = "item", required = true) final Item item) {
-        
+        items.put(item.getName(), item);
         return Response
             .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
             .entity(item).build();
@@ -105,8 +113,10 @@ public class Sample {
     )
     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);
+        @ApiParam(value = "value", required = true) @FormParam("value") String value) {
+        Item item = new Item(name, value);
+        items.put(name,  item);
+        return item;
     }
     
     @Path("/{name}")
@@ -125,6 +135,7 @@ public class Sample {
        )
     )
     public Response delete(@ApiParam(value = "name", required = true) @PathParam("name")
String name) {
+        items.remove(name);
         return Response.ok().build();
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/f3711938/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample.java
b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample.java
index 56d3213..4080348 100644
--- a/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample.java
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger2_web/src/main/java/demo/jaxrs/swagger/server/Sample.java
@@ -20,6 +20,9 @@
 package demo.jaxrs.swagger.server;
 
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -47,6 +50,15 @@ import io.swagger.annotations.ApiParam;
 @Path("/sample") 
 @Api(value = "/sample", description = "Sample JAX-RS service with Swagger documentation")
 public class Sample {
+    private Map<String, Item> items;
+
+    public Sample() {
+        items = Collections.synchronizedMap(new TreeMap<String, Item>(String.CASE_INSENSITIVE_ORDER));
+        items.put("Item 1", new Item("Item 1", "Value 1"));
+        items.put("Item 2", new Item("Item 2", "Value 2"));
+    }
+        
+    
     @Produces({ MediaType.APPLICATION_JSON })
     @GET
     @ApiOperation(
@@ -57,12 +69,8 @@ public class Sample {
     )
     public Response getItems(
         @ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1")
int page) {
-        return Response.ok(
-            Arrays.asList(
-                new Item("Item 1", "Value 1"),
-                new Item("Item 2", "Value 2")
-            )
-        ).build();
+
+        return Response.ok(items.values()).build();
     }
     
     @Produces({ MediaType.APPLICATION_JSON })
@@ -76,7 +84,7 @@ public class Sample {
     public Item getItem(
         @ApiParam(value = "language", required = true) @HeaderParam("Accept-Language") final
String language,
         @ApiParam(value = "name", required = true) @PathParam("name") String name) {
-        return new Item("name", "Value in " + language);
+        return items.get(name);
     }
     
     @Consumes({ MediaType.APPLICATION_JSON })
@@ -89,7 +97,7 @@ public class Sample {
     public Response createItem(
         @Context final UriInfo uriInfo,
         @ApiParam(value = "item", required = true) final Item item) {
-        
+        items.put(item.getName(), item);
         return Response
             .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
             .entity(item).build();
@@ -105,8 +113,10 @@ public class Sample {
     )
     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);
+        @ApiParam(value = "value", required = true) @FormParam("value") String value) {
+        Item item = new Item(name, value);
+        items.put(name,  item);
+        return item;
     }
     
     @Path("/{name}")
@@ -125,6 +135,7 @@ public class Sample {
        )
     )
     public Response delete(@ApiParam(value = "name", required = true) @PathParam("name")
String name) {
+        items.remove(name);
         return Response.ok().build();
     }
 }


Mime
View raw message