Merge branch 'master' of https://gitbox.apache.org/repos/asf/juneau-petstore.git master
authorJamesBognar <james.bognar@salesforce.com>
Thu, 23 Jun 2022 20:09:33 +0000 (16:09 -0400)
committerJamesBognar <james.bognar@salesforce.com>
Thu, 23 Jun 2022 20:09:33 +0000 (16:09 -0400)
26 files changed:
.asf.yaml [new file with mode: 0644]
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/PetStore.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/CreateOrder.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/CreatePet.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/ExpiresAfter.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/IdConflict.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/IdNotFound.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/InvalidId.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/InvalidLogin.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/InvalidSpecies.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/InvalidTag.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/InvalidUsername.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/Order.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/Pet.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/PetTag.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/PetTagNameSwap.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/UpdatePet.java
juneau-petstore-api/src/main/java/org/apache/juneau/petstore/dto/User.java
juneau-petstore-client/src/main/java/org/apache/juneau/petstore/Main.java
juneau-petstore-server/pom.xml
juneau-petstore-server/src/main/java/org/apache/juneau/petstore/App.java
juneau-petstore-server/src/main/java/org/apache/juneau/petstore/AppConfiguration.java [deleted file]
juneau-petstore-server/src/main/java/org/apache/juneau/petstore/rest/PetStoreResource.java
juneau-petstore-server/src/main/java/org/apache/juneau/petstore/rest/RootResources.java
juneau-petstore-server/src/test/java/org/apache/juneau/petstore/test/MockTest.java
pom.xml

diff --git a/.asf.yaml b/.asf.yaml
new file mode 100644 (file)
index 0000000..a4e3f3c
--- /dev/null
+++ b/.asf.yaml
@@ -0,0 +1,21 @@
+notifications:
+  commits:      commits@juneau.apache.org
+  issues:       dev@juneau.apache.org
+  pullrequests: dev@juneau.apache.org
+  jira_options: link label worklog
+  jobs:         dev@juneau.apache.org
+  discussions:  dev@juneau.apache.org
+  
+github:
+  description: "Apache Juneau"
+  homepage: https://juneau.apache.org/
+  labels:
+    - json
+    - juneau
+    - http
+    - rest
+    - apache
+  features:
+    wiki: true
+    issues: true
+    projects: true
\ No newline at end of file
index 76d184fbb0cbf6d281d0047899022f9badf67599..89aa1f1cdcfa0b52be20f36cd720746ba8a8834e 100755 (executable)
 // ***************************************************************************************************************************
 package org.apache.juneau.petstore;
 
-import static org.apache.juneau.http.HttpMethod.*;
-
 import java.util.*;
 
-import org.apache.juneau.jsonschema.annotation.Items;
 import org.apache.juneau.petstore.dto.*;
 import org.apache.juneau.*;
 import org.apache.juneau.http.annotation.*;
 import org.apache.juneau.http.remote.*;
-import org.apache.juneau.http.exception.*;
 import org.apache.juneau.http.response.*;
 
 /**
@@ -50,7 +46,7 @@ public interface PetStore {
         * @return All pets in the database.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=GET, path="/pet")
+       @RemoteGet("/pet")
        public Collection<Pet> getPets() throws NotAcceptable;
 
        /**
@@ -61,12 +57,11 @@ public interface PetStore {
         * @throws IdNotFound Pet was not found.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(path="/pet/{petId}") /* method inferred from method name */
+       @RemoteGet("/pet/{petId}") /* method inferred from method name */
        public Pet getPet(
                @Path(
                        name="petId",
-                       description="ID of pet to return",
-                       example="123"
+                       schema=@Schema(description="ID of pet to return")
                )
                long petId
        ) throws IdNotFound, NotAcceptable;
@@ -80,11 +75,12 @@ public interface PetStore {
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         * @throws UnsupportedMediaType Unsupported <c>Content-Type</c> header specified.
         */
-       @RemoteMethod(method=POST, path="/pet")
+       @RemotePost("/pet")
        public long createPet(
-               @Body(
-                       description="Pet object to add to the store"
-               ) CreatePet pet
+               @Content(
+                       schema=@Schema(description="Pet object to add to the store")
+               )
+               CreatePet pet
        ) throws IdConflict, NotAcceptable, UnsupportedMediaType;
 
        /**
@@ -96,11 +92,12 @@ public interface PetStore {
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         * @throws UnsupportedMediaType Unsupported <c>Content-Type</c> header specified.
         */
-       @RemoteMethod(method=PUT, path="/pet/{petId}")
+       @RemotePut("/pet/{petId}")
        public Ok updatePet(
-               @Body(
-                       description="Pet object that needs to be added to the store"
-               ) UpdatePet pet
+               @Content(
+                       schema=@Schema(description="Pet object that needs to be added to the store")
+               )
+               UpdatePet pet
        ) throws IdNotFound, NotAcceptable, UnsupportedMediaType;
 
        /**
@@ -110,20 +107,21 @@ public interface PetStore {
         * @return The pets that match the specified statuses.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=GET, path="/pet/findByStatus")
+       @RemoteGet("/pet/findByStatus")
        public Collection<Pet> findPetsByStatus(
                @Query(
                        name="status",
-                       description="Status values that need to be considered for filter.",
-                       required=true,
-                       type="array",
-                       collectionFormat="csv",
-                       items=@Items(
-                               type="string",
-                               _enum="AVAILABLE,PENDING,SOLD",
-                               _default="AVAILABLE"
-                       ),
-                       example="AVALIABLE,PENDING"
+                       schema=@Schema(
+                               description="Status values that need to be considered for filter.",
+                               required=true,
+                               type="array",
+                               collectionFormat="csv",
+                               items=@Items(
+                                       type="string",
+                                       _enum="AVAILABLE,PENDING,SOLD",
+                                       _default="AVAILABLE"
+                               )
+                       )
                )
                PetStatus[] status
        ) throws NotAcceptable;
@@ -137,19 +135,19 @@ public interface PetStore {
         * @throws IdNotFound Pet not found.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=DELETE, path="/pet/{petId}")
+       @RemoteDelete("/pet/{petId}")
        public Ok deletePet(
                @Header(
                        name="api_key",
-                       description="Security API key",
-                       required=true,
-                       example="foobar"
+                       schema=@Schema(
+                               description="Security API key",
+                               required=true
+                       )
                )
                String apiKey,
                @Path(
                        name="petId",
-                       description="Pet id to delete",
-                       example="123"
+                       schema=@Schema(description="Pet id to delete")
                )
                long petId
        ) throws IdNotFound, NotAcceptable;
@@ -159,7 +157,7 @@ public interface PetStore {
         *
         * @return {@link Ok} if successful.
         */
-       @RemoteMethod(method=DELETE, path="/pet")
+       @RemoteDelete("/pet")
        public Ok deleteAllPets();
 
        //------------------------------------------------------------------------------------------------------------------
@@ -172,7 +170,7 @@ public interface PetStore {
         * @return All orders in the database.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=GET, path="/store/order")
+       @RemoteGet("/store/order")
        public Collection<Order> getOrders() throws NotAcceptable;
 
        /**
@@ -184,14 +182,15 @@ public interface PetStore {
         * @throws IdNotFound Order was not found.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=GET, path="/store/order/{orderId}")
+       @RemoteGet("/store/order/{orderId}")
        public Order getOrder(
                @Path(
                        name="orderId",
-                       description="ID of order to fetch",
-                       maximum="1000",
-                       minimum="1",
-                       example="123"
+                       schema=@Schema(
+                               description="ID of order to fetch",
+                               maximum="1000",
+                               minimum="1"
+                       )
                )
                long orderId
        ) throws InvalidId, IdNotFound, NotAcceptable;
@@ -206,16 +205,16 @@ public interface PetStore {
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         * @throws UnsupportedMediaType Unsupported <c>Content-Type</c> header specified.
         */
-       @RemoteMethod(method=POST, path="/store/order")
+       @RemotePost("/store/order")
        public long placeOrder(
                @FormData(
                        name="petId",
-                       description="Pet ID"
+                       schema=@Schema(description="Pet ID")
                )
                long petId,
                @FormData(
                        name="username",
-                       description="The username of the user creating the order"
+                       schema=@Schema(description="The username of the user creating the order")
                )
                String username
        ) throws IdConflict, NotAcceptable, UnsupportedMediaType;
@@ -229,13 +228,14 @@ public interface PetStore {
         * @throws IdNotFound Order not found.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=DELETE, path="/store/order/{orderId}")
+       @RemoteDelete("/store/order/{orderId}")
        public Ok deleteOrder(
                @Path(
                        name="orderId",
-                       description="ID of the order that needs to be deleted",
-                       minimum="1",
-                       example="5"
+                       schema=@Schema(
+                               description="ID of the order that needs to be deleted",
+                               minimum="1"
+                       )
                )
                long orderId
        ) throws InvalidId, IdNotFound, NotAcceptable;
@@ -245,7 +245,7 @@ public interface PetStore {
         *
         * @return {@link Ok} if successful.
         */
-       @RemoteMethod(method=DELETE, path="/store/order")
+       @RemoteDelete("/store/order")
        public Ok deleteAllOrders();
 
        /**
@@ -254,7 +254,7 @@ public interface PetStore {
         * @return An inventory of pet statuses and counts.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=GET, path="/store/inventory")
+       @RemoteGet("/store/inventory")
        public Map<PetStatus,Integer> getStoreInventory() throws NotAcceptable;
 
        //------------------------------------------------------------------------------------------------------------------
@@ -267,7 +267,7 @@ public interface PetStore {
         * @return All users in the database.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=GET, path="/user")
+       @RemoteGet("/user")
        public Collection<User> getUsers() throws NotAcceptable;
 
        /**
@@ -279,11 +279,11 @@ public interface PetStore {
         * @throws IdNotFound username not found.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=GET, path="/user/{username}")
+       @RemoteGet("/user/{username}")
        public User getUser(
                @Path(
                        name="username",
-                       description="The name that needs to be fetched. Use user1 for testing."
+                       schema=@Schema(description="The name that needs to be fetched. Use user1 for testing.")
                )
                String username
        ) throws InvalidUsername, IdNotFound, NotAcceptable;
@@ -298,10 +298,10 @@ public interface PetStore {
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         * @throws UnsupportedMediaType Unsupported <c>Content-Type</c> header specified.
         */
-       @RemoteMethod(method=POST, path="/user")
+       @RemotePost("/user")
        public Ok createUser(
-               @Body(
-                       description="Created user object"
+               @Content(
+                       schema=@Schema(description="Created user object")
                )
                User user
        ) throws InvalidUsername, IdConflict, NotAcceptable, UnsupportedMediaType;
@@ -316,10 +316,10 @@ public interface PetStore {
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         * @throws UnsupportedMediaType Unsupported <c>Content-Type</c> header specified.
         */
-       @RemoteMethod(method=POST, path="/user/createWithArray")
+       @RemotePost("/user/createWithArray")
        public Ok createUsers(
-               @Body(
-                       description="List of user objects"
+               @Content(
+                       schema=@Schema(description="List of user objects")
                )
                User[] users
        ) throws InvalidUsername, IdConflict, NotAcceptable, UnsupportedMediaType;
@@ -335,15 +335,15 @@ public interface PetStore {
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         * @throws UnsupportedMediaType Unsupported <c>Content-Type</c> header specified.
         */
-       @RemoteMethod(method=PUT, path="/user/{username}")
+       @RemotePut("/user/{username}")
        public Ok updateUser(
                @Path(
                        name="username",
-                       description="Name that need to be updated"
+                       schema=@Schema(description="Name that need to be updated")
                )
                String username,
-               @Body(
-                       description="Updated user object"
+               @Content(
+                       schema=@Schema(description="Updated user object")
                )
                User user
        ) throws InvalidUsername, IdNotFound, NotAcceptable, UnsupportedMediaType;
@@ -357,11 +357,11 @@ public interface PetStore {
         * @throws IdNotFound User was not found.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=DELETE, path="/user/{username}")
+       @RemoteDelete("/user/{username}")
        public Ok deleteUser(
                @Path(
                        name="username",
-                       description="The name that needs to be deleted"
+                       schema=@Schema(description="The name that needs to be deleted")
                )
                String username
        ) throws InvalidUsername, IdNotFound, NotAcceptable;
@@ -371,7 +371,7 @@ public interface PetStore {
         *
         * @return {@link Ok} if successful.
         */
-       @RemoteMethod(method=DELETE, path="/user")
+       @RemoteDelete("/user")
        public Ok deleteAllUsers();
 
        /**
@@ -379,36 +379,29 @@ public interface PetStore {
         *
         * @param username The username for login.
         * @param password The password for login in clear text.
-        * @param rateLimit Calls per hour allowed by the user.
         * @param expiresAfter The <bc>Expires-After</bc> response header.
         * @return {@link Ok} if successful.
         * @throws InvalidLogin Login was unsuccessful.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=GET, path="/user/login")
+       @RemoteGet("/user/login")
        public Ok login(
                @Query(
                        name="username",
-                       description="The username for login.",
-                       required=true,
-                       example="myuser"
+                       schema=@Schema(
+                               description="The username for login.",
+                               required=true
+                       )
                )
                String username,
                @Query(
                        name="password",
-                       description="The password for login in clear text.",
-                       required=true,
-                       example="abc123"
+                       schema=@Schema(
+                               description="The password for login in clear text.",
+                               required=true
+                       )
                )
                String password,
-               @ResponseHeader(
-                       name="X-Rate-Limit",
-                       type="integer",
-                       format="int32",
-                       description="Calls per hour allowed by the user.",
-                       example="123"
-               )
-               Value<Integer> rateLimit,
                Value<ExpiresAfter> expiresAfter
        ) throws InvalidLogin, NotAcceptable;
 
@@ -418,6 +411,6 @@ public interface PetStore {
         * @return {@link Ok} if successful.
         * @throws NotAcceptable Unsupported <c>Accept</c> header specified.
         */
-       @RemoteMethod(method=GET, path="/user/logout")
+       @RemoteGet("/user/logout")
        public Ok logout() throws NotAcceptable;
 }
index 108d632ea273a9e4c45375af96ccf03a2ee78817..2bacf4ab57a9699be5f3d577edaf7301a5bea8e3 100755 (executable)
@@ -21,7 +21,7 @@ import org.apache.juneau.annotation.*;
  *     <li class='extlink'>{@source}
  * </ul>
  */
-@Bean(fluentSetters=true, properties="petId,username")
+@Bean(findFluentSetters=true, properties="petId,username")
 public class CreateOrder {
 
        private long petId;
index a8866161392fbbb5df175ac7dbb96a5a02847779..55d79821951f7e3870afc57b8b461429791cd604 100755 (executable)
@@ -13,7 +13,7 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.annotation.*;
-import org.apache.juneau.jsonschema.annotation.*;
+import org.apache.juneau.http.annotation.Schema;
 
 /**
  * Bean for creating {@link Pet} objects.
@@ -22,7 +22,7 @@ import org.apache.juneau.jsonschema.annotation.*;
  *     <li class='extlink'>{@source}
  * </ul>
  */
-@Bean(fluentSetters=true, properties="name,price,species,tags")
+@Bean(findFluentSetters=true, properties="name,price,species,tags")
 public class CreatePet {
 
        @Schema(description="Pet name.", minLength=3, maxLength=50)
@@ -34,7 +34,7 @@ public class CreatePet {
        @Schema(description="Pet species.")
        private Species species;
 
-       @Schema(description="Pet attributes.", example="friendly,smart")
+       @Schema(description="Pet attributes.")
        private String[] tags;
 
        /**
index 8273edfe18a83a34975b4537f9094196f15452fc..454b954f4a6bfb2e85f1aba2eb82b7d923a422f3 100755 (executable)
@@ -23,12 +23,13 @@ import org.apache.juneau.http.annotation.*;
  *     <li class='extlink'>{@source}
  * </ul>
  */
-@ResponseHeader(
+@Header(
        name="X-Expires-After",
-       type="string",
-       format="date-time",
-       description="Date in UTC when token expires",
-       example="2012-10-21"
+       schema=@Schema(
+               type="string",
+               format="date-time",
+               description="Date in UTC when token expires"
+       )
 )
 public class ExpiresAfter {
        private final Calendar c;
index 5a22a1d29a9602a63845e866e7e07d2e63f7d885..20a3c208a6c4826506e5124daab9c2b7fd1ffa64 100755 (executable)
@@ -13,7 +13,7 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.http.exception.*;
+import org.apache.juneau.http.response.Conflict;
 
 /**
  * Exception thrown when trying to add an entry where the ID is already in use.
@@ -23,7 +23,7 @@ import org.apache.juneau.http.exception.*;
  * </ul>
  */
 @SuppressWarnings("serial")
-@Response(description="ID already in use")
+@Response(schema=@Schema(description="ID already in use"))
 public class IdConflict extends Conflict {
 
        /**
index b086f8ed8487db7fdd65429da3ec5e74e11d69b6..39cdf769b91182106698808e1c7bce3437bf9d94 100755 (executable)
@@ -13,7 +13,7 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.http.exception.*;
+import org.apache.juneau.http.response.NotFound;
 
 /**
  * Exception thrown when trying to add an entry where the ID is already in use.
@@ -23,7 +23,7 @@ import org.apache.juneau.http.exception.*;
  * </ul>
  */
 @SuppressWarnings("serial")
-@Response(description="ID not found")
+@Response
 public class IdNotFound extends NotFound {
 
        /**
index d7ee80731fe5dfe7063b146b9b9b3151a7456d68..f7baee3c7ede74409278cb7cd0693da12f58389f 100755 (executable)
@@ -13,7 +13,7 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.http.exception.*;
+import org.apache.juneau.http.response.BadRequest;
 
 /**
  * Exception thrown when trying to add an entry where the ID is already in use.
@@ -23,7 +23,7 @@ import org.apache.juneau.http.exception.*;
  * </ul>
  */
 @SuppressWarnings("serial")
-@Response(description="Invalid ID provided")
+@Response(schema=@Schema(description="Invalid ID provided"))
 public class InvalidId extends BadRequest {
 
        /**
index 25f6bd90446fbc1823ac70b5dbb9260c38c11864..9a1efadc4c3b25173d57cea8f731b06d78a74511 100755 (executable)
@@ -13,7 +13,7 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.http.exception.*;
+import org.apache.juneau.http.response.Unauthorized;
 
 /**
  * Exception thrown when an invalid username or password is provided.
@@ -23,7 +23,7 @@ import org.apache.juneau.http.exception.*;
  * </ul>
  */
 @SuppressWarnings("serial")
-@Response(description="Invalid username or password provided")
+@Response(schema=@Schema(description="Invalid username or password provided"))
 public class InvalidLogin extends Unauthorized {
 
        /**
index 19cef69ec26fa91a51421b1875982cab704498fb..78158678463d9166cd115fe383bfb14af94bedd1 100755 (executable)
@@ -13,7 +13,7 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.http.exception.*;
+import org.apache.juneau.http.response.BadRequest;
 
 /**
  * Exception thrown when an invalid species is looked up.
@@ -23,7 +23,7 @@ import org.apache.juneau.http.exception.*;
  * </ul>
  */
 @SuppressWarnings("serial")
-@Response(description="Invalid species provided")
+@Response(schema=@Schema(description="Invalid species provided"))
 public class InvalidSpecies extends BadRequest {
 
        /**
index 4e2199ecbe8b36cd0e48e760b1c26fbed5ab8cfb..663fb45aa25eea6ef1fe434cce5fbbf4353f09d8 100755 (executable)
@@ -13,7 +13,7 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.http.exception.*;
+import org.apache.juneau.http.response.BadRequest;
 
 /**
  * Exception thrown when trying to add an entry where the ID is already in use.
@@ -23,7 +23,7 @@ import org.apache.juneau.http.exception.*;
  * </ul>
  */
 @SuppressWarnings("serial")
-@Response(description="Invalid tag provided")
+@Response(schema=@Schema(description="Invalid tag provided"))
 public class InvalidTag extends BadRequest {
 
        /**
index 46644a325eee0e40396344cfa42fe75a1bb502f3..1645c29b052342ca51c6b1ca2549f70f1631c5ba 100755 (executable)
@@ -13,7 +13,7 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.http.exception.*;
+import org.apache.juneau.http.response.BadRequest;
 
 /**
  * Exception thrown when trying to add an entry where the ID is already in use.
@@ -23,7 +23,7 @@ import org.apache.juneau.http.exception.*;
  * </ul>
  */
 @SuppressWarnings("serial")
-@Response(description="Invalid username provided")
+@Response(schema=@Schema(description="Invalid username provided"))
 public class InvalidUsername extends BadRequest {
 
        /**
index 27fb0b38a0b0e8438fe86257d72c42503d1b4951..b3bbd34de17752b8a230b2f03dd6240c5904058d 100755 (executable)
@@ -20,9 +20,9 @@ import javax.persistence.*;
 
 import org.apache.juneau.annotation.*;
 import org.apache.juneau.html.annotation.*;
+import org.apache.juneau.http.annotation.Schema;
 import org.apache.juneau.internal.*;
-import org.apache.juneau.jsonschema.annotation.*;
-import org.apache.juneau.transforms.*;
+import org.apache.juneau.swaps.TemporalDateSwap;
 
 /**
  * Order bean.
@@ -31,7 +31,7 @@ import org.apache.juneau.transforms.*;
  *     <li class='extlink'>{@source}
  * </ul>
  */
-@Bean(fluentSetters=true, properties="id,petId,username,status,shipDate")
+@Bean(findFluentSetters=true, properties="id,petId,username,status,shipDate")
 @Example("{id:123,petId:456,shipDate:'2012-12-21',status:'APPROVED'}")
 @Entity(name="PetstoreOrder")
 public class Order {
@@ -188,7 +188,7 @@ public class Order {
                        .username("sampleuser")
                        .petId(456)
                        .status(OrderStatus.APPROVED)
-                       .shipDate(DateUtils.parseISO8601("2020-10-10"))
+                       .shipDate(DateUtils.parseISO8601Calendar("2020-10-10").getTime())
                ;
        }
 }
index c7fb76baed7550adab231ec9bd8cc3ee3d8562dc..24ce04589a563cdc5f28d3638091df8de2e6a387 100755 (executable)
@@ -21,7 +21,7 @@ import javax.persistence.*;
 import org.apache.juneau.annotation.*;
 import org.apache.juneau.html.*;
 import org.apache.juneau.html.annotation.*;
-import org.apache.juneau.jsonschema.annotation.*;
+import org.apache.juneau.http.annotation.Schema;
 import org.apache.juneau.serializer.*;
 
 /**
@@ -31,7 +31,7 @@ import org.apache.juneau.serializer.*;
  *     <li class='extlink'>{@source}
  * </ul>
  */
-@Bean(typeName="Pet", fluentSetters=true, properties="id,species,name,tags,price,status")
+@Bean(typeName="Pet", findFluentSetters=true, properties="id,species,name,tags,price,status")
 @Entity(name="PetstorePet")
 public class Pet {
 
@@ -54,7 +54,7 @@ public class Pet {
        private Species species;
 
        @ElementCollection(fetch=FetchType.EAGER) @OrderColumn
-       @Schema(description="Pet attributes.", example="friendly,smart")
+       @Schema(description="Pet attributes.")
        private List<String> tags;
 
        @Column @Enumerated(STRING)
index 34577ab0b346a2fe7fae5663bc68590778c93f05..c6d01789c0a1cb37dfc2f0a7dde2e4ee0dcee9af 100755 (executable)
@@ -24,7 +24,7 @@ import org.apache.juneau.internal.*;
  *     <li class='extlink'>{@source}
  * </ul>
  */
-@Bean(typeName="Tag", fluentSetters=true)
+@Bean(typeName="Tag", findFluentSetters=true)
 @Swap(PetTagNameSwap.class)
 public class PetTag {
        private long id;
index 7e1442f39512459fec9c4e1e781cd5cd39885c53..67a258a64af3319c183d5fdc33bf07fc02e8aa1b 100755 (executable)
@@ -13,8 +13,8 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.*;
-import org.apache.juneau.http.*;
-import org.apache.juneau.transform.*;
+import org.apache.juneau.http.header.MediaType;
+import org.apache.juneau.swap.StringSwap;
 
 /**
  * Swap for {@link PetTag} beans.
@@ -23,7 +23,7 @@ import org.apache.juneau.transform.*;
  *     <li class='extlink'>{@source}
  * </ul>
  */
-public class PetTagNameSwap extends PojoSwap<PetTag,String> {
+public class PetTagNameSwap extends StringSwap<PetTag> {
 
        /**
         * Swap PetTag with name.
index d4b671f93fa17016b340100b9f83a8123f95f438..1f6aae6d08514f76e277cdaced141d801e2e0675 100755 (executable)
@@ -13,7 +13,7 @@
 package org.apache.juneau.petstore.dto;
 
 import org.apache.juneau.annotation.*;
-import org.apache.juneau.jsonschema.annotation.*;
+import org.apache.juneau.http.annotation.Schema;
 
 /**
  * Bean for updating {@link Pet} objects.
@@ -22,7 +22,7 @@ import org.apache.juneau.jsonschema.annotation.*;
  *     <li class='extlink'>{@source}
  * </ul>
  */
-@Bean(fluentSetters=true, properties="id,name,price,species,tags,status")
+@Bean(findFluentSetters=true, properties="id,name,price,species,tags,status")
 public class UpdatePet extends CreatePet {
 
        @Schema(description="Pet identifier.", minimum="1")
index eefa4c5a612c6183f1032d15ada0246763726016..f8730ceb1c37846b090017da3a314297304b9129 100755 (executable)
@@ -18,7 +18,7 @@ import javax.persistence.*;
 
 import org.apache.juneau.annotation.*;
 import org.apache.juneau.html.annotation.*;
-import org.apache.juneau.jsonschema.annotation.*;
+import org.apache.juneau.http.annotation.Schema;
 
 /**
  * User bean.
@@ -27,7 +27,7 @@ import org.apache.juneau.jsonschema.annotation.*;
  *     <li class='extlink'>{@source}
  * </ul>
  */
-@Bean(typeName="User", fluentSetters=true, properties="username,firstName,lastName,email,password,phone,userStatus")
+@Bean(typeName="User", findFluentSetters=true, properties="username,firstName,lastName,email,password,phone,userStatus")
 @Entity(name="PetstoreUser")
 public class User {
 
index 7560b142722ed36c304affbd92b56cdbecc18ca2..9f851e81317e358cb154452b30cc14fcf6073af1 100755 (executable)
@@ -21,7 +21,7 @@ import org.apache.juneau.json.*;
 import org.apache.juneau.marshall.*;
 import org.apache.juneau.parser.*;
 import org.apache.juneau.petstore.dto.*;
-import org.apache.juneau.rest.client2.*;
+import org.apache.juneau.rest.client.*;
 
 /**
  * Example code showing how to connect to the PetStore application using a remote proxy.
index c6ed17963cb1cf911caf05875e9a7f2dd0853e64..fa31dc0a99ae80fbed0e9ef341e5d29950d070b3 100755 (executable)
@@ -41,7 +41,7 @@
 
                <maven.javadoc.skip>true</maven.javadoc.skip>
 
-               <juneau.version>8.2.0</juneau.version>
+               <juneau.version>9.0.0-SNAPSHOT</juneau.version>
        </properties>
 
        <packaging>war</packaging>
index a124a63c7a9958f9722d48dbb11ab43d2f83e303..83d43650dc2ec8299ec1fcf169039c767fcf7c9d 100755 (executable)
@@ -14,13 +14,18 @@ package org.apache.juneau.petstore;
 
 import java.io.*;
 
+import javax.servlet.*;
+
+import org.apache.juneau.petstore.rest.*;
 import org.apache.juneau.petstore.service.*;
-import org.apache.juneau.rest.springboot.JuneauRestInitializer;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.*;
 import org.springframework.cache.annotation.EnableCaching;
 import org.springframework.context.*;
+import org.springframework.context.annotation.*;
 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.stereotype.*;
 
 /**
  * Entry point for PetStore application.
@@ -29,21 +34,43 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
 @EnableJpaRepositories(basePackages = "org.apache.juneau.petstore")
 @EnableCaching
 @SuppressWarnings("javadoc")
+@Controller
 public class App {
 
-       public static void main(String[] args) {
-               new App().start(args);
-       }
-
-       protected void start(String[] args) {
-               ConfigurableApplicationContext ctx = new SpringApplicationBuilder(App.class)
-                       .initializers(new JuneauRestInitializer(App.class)) // Needed for Juneau resources as injectible Spring beans.
-                       .run(args);
+       //-----------------------------------------------------------------------------------------------------------------
+       // Beans
+       //-----------------------------------------------------------------------------------------------------------------
 
+       public static void main(String[] args) {
                try {
+                       ConfigurableApplicationContext ctx = new SpringApplicationBuilder(App.class).run(args);
                        ctx.getBean(PetStoreService.class).initDirect(new PrintWriter(System.out));
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
+
+       //-----------------------------------------------------------------------------------------------------------------
+       // Beans
+       //-----------------------------------------------------------------------------------------------------------------
+
+       @Bean
+       public PetStoreService petStoreService() {
+               return new PetStoreService();
+       }
+
+       @Bean
+       public RootResources rootResources() {
+               return new RootResources();
+       }
+
+       @Bean
+       public PetStoreResource petStoreResource() {
+               return new PetStoreResource();
+       }
+
+       @Bean
+       public ServletRegistrationBean<Servlet> getRootServlet(RootResources rootResources) {
+               return new ServletRegistrationBean<>(rootResources, "/*");
+       }
 }
diff --git a/juneau-petstore-server/src/main/java/org/apache/juneau/petstore/AppConfiguration.java b/juneau-petstore-server/src/main/java/org/apache/juneau/petstore/AppConfiguration.java
deleted file mode 100755 (executable)
index 79ccb12..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// ***************************************************************************************************************************
-// * 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.juneau.petstore;
-
-
-import org.apache.juneau.petstore.rest.*;
-import org.apache.juneau.petstore.service.*;
-import org.apache.juneau.rest.springboot.annotation.JuneauRestRoot;
-import org.springframework.context.annotation.*;
-
-@SuppressWarnings("javadoc")
-@Configuration
-public class AppConfiguration {
-
-       //-----------------------------------------------------------------------------------------------------------------
-       // Services
-       //-----------------------------------------------------------------------------------------------------------------
-
-       @Bean
-       public PetStoreService petStoreService() {
-               return new PetStoreService();
-       }
-
-       //-----------------------------------------------------------------------------------------------------------------
-       // REST
-       //-----------------------------------------------------------------------------------------------------------------
-
-       @Bean
-       @JuneauRestRoot
-       public RootResources rootResources2() {
-               return new RootResources();
-       }
-
-       @Bean
-       public PetStoreResource petStoreResource() {
-               return new PetStoreResource();
-       }
-}
index 642c6dea2d1e4fad649bc69c5029ab62603892cc..73c5dfb51ea74f0daea07d69b97a27f61526dc7c 100755 (executable)
 // ***************************************************************************************************************************\r
 package org.apache.juneau.petstore.rest;\r
 \r
-import static org.apache.juneau.dto.swagger.ui.SwaggerUI.*;\r
-import static org.apache.juneau.http.HttpMethod.*;\r
 import static org.apache.juneau.http.response.Ok.*;\r
 \r
 import java.util.*;\r
 import java.util.Map;\r
 \r
-import org.apache.juneau.jsonschema.annotation.*;\r
 import org.apache.juneau.petstore.*;\r
 import org.apache.juneau.petstore.dto.*;\r
 import org.apache.juneau.petstore.service.*;\r
@@ -29,14 +26,14 @@ import org.apache.juneau.html.annotation.*;
 import org.apache.juneau.http.annotation.*;\r
 import org.apache.juneau.rest.*;\r
 import org.apache.juneau.rest.annotation.*;\r
-import org.apache.juneau.http.exception.*;\r
-import org.apache.juneau.rest.helper.*;\r
+import org.apache.juneau.rest.beans.*;\r
+import org.apache.juneau.rest.config.*;\r
+import org.apache.juneau.rest.converter.*;\r
+import org.apache.juneau.rest.servlet.*;\r
 import org.apache.juneau.http.response.*;\r
 import org.apache.juneau.rest.widget.*;\r
-import org.apache.juneau.transforms.*;\r
+import org.apache.juneau.swaps.*;\r
 import org.springframework.beans.factory.annotation.*;\r
-import org.springframework.web.bind.annotation.CrossOrigin;\r
-import org.apache.juneau.rest.converters.*;\r
 \r
 /**\r
  * Sample Petstore application.\r
@@ -52,11 +49,7 @@ import org.apache.juneau.rest.converters.*;
                "This is a sample server Petstore server based on the Petstore sample at Swagger.io.",\r
                "You can find out more about Swagger at http://swagger.io.",\r
        },\r
-       properties= {\r
-               // Resolve recursive references when showing schema info in the swagger.\r
-               @Property(name=SWAGGERUI_resolveRefsMaxDepth, value="99")\r
-       },\r
-       swagger=@ResourceSwagger(\r
+       swagger=@Swagger(\r
                version="1.0.0",\r
                title="Swagger Petstore",\r
                termsOfService="You are on your own.",\r
@@ -95,8 +88,7 @@ import org.apache.juneau.rest.converters.*;
                                )\r
                        )\r
                }\r
-       ),\r
-       staticFiles={"htdocs:/htdocs"}  // Expose static files in htdocs subpackage.\r
+       )\r
 )\r
 @HtmlDocConfig(\r
        widgets={\r
@@ -104,7 +96,8 @@ import org.apache.juneau.rest.converters.*;
        },\r
        navlinks={\r
                "up: request:/..",\r
-               "options: servlet:/?method=OPTIONS",\r
+               "api: servlet:/api",\r
+               "stats: servlet:/stats",\r
                "$W{ContentTypeMenuItem}",\r
                "source: $C{Source/gitHub}/org/apache/juneau/petstore/rest/$R{servletClassSimple}.java"\r
        },\r
@@ -112,8 +105,8 @@ import org.apache.juneau.rest.converters.*;
                "<link rel='icon' href='$U{servlet:/htdocs/cat.png}'/>"  // Add a cat icon to the page.\r
        },\r
        header={\r
-               "<h1>$R{resourceTitle}</h1>",\r
-               "<h2>$R{methodSummary}</h2>",\r
+               "<h1>$RS{title}</h1>",  // Use @Rest(title)\r
+               "<h2>$RS{operationSummary,description}</h2>", // Use either @RestOp(summary) or @Rest(description)\r
                "$C{PetStore/headerImage}"\r
        },\r
        aside={\r
@@ -126,7 +119,7 @@ import org.apache.juneau.rest.converters.*;
        },\r
        stylesheet="servlet:/htdocs/themes/dark.css"  // Use dark theme by default.\r
 )\r
-public class PetStoreResource extends BasicRest implements PetStore {\r
+public class PetStoreResource extends BasicRestObject implements BasicUniversalConfig, PetStore {\r
 \r
        @Autowired\r
        private PetStoreService store;\r
@@ -136,8 +129,7 @@ public class PetStoreResource extends BasicRest implements PetStore {
         *\r
         * @return Navigation page contents.\r
         */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/",\r
                summary="Navigation page"\r
        )\r
@@ -165,11 +157,10 @@ public class PetStoreResource extends BasicRest implements PetStore {
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/pet",\r
                summary="All pets in the store",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="pet",\r
                        parameters={\r
                                Queryable.SWAGGER_PARAMS  // Documents searching.\r
@@ -177,21 +168,17 @@ public class PetStoreResource extends BasicRest implements PetStore {
                ),\r
                converters={Queryable.class}  // Searching support.\r
        )\r
-       @BeanConfig(\r
-               bpx="Pet: tags,photo"  // In this view, don't serialize tags/photos properties.\r
-       )\r
+       @Bean(on="Pet", excludeProperties="tags,photo")\r
        public Collection<Pet> getPets() throws NotAcceptable {\r
                return store.getPets();\r
        }\r
 \r
        @Override /* PetStore */\r
-       @CrossOrigin(origins = "http://localhost:3000", maxAge = 3600)\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/pet/{petId}",\r
                summary="Find pet by ID",\r
                description="Returns a single pet",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="pet"\r
                )\r
        )\r
@@ -200,11 +187,10 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=POST,\r
+       @RestPost(\r
                path="/pet",\r
                summary="Add a new pet to the store",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="pet"\r
                )\r
                //roleGuard="ROLE_ADMIN || (ROLE_USER && ROLE_WRITABLE)"  // Restrict access to this method.\r
@@ -214,11 +200,10 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=PUT,\r
+       @RestPut(\r
                path="/pet/{petId}",\r
                summary="Update an existing pet",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="pet"\r
                )\r
        )\r
@@ -228,12 +213,11 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/pet/findByStatus",\r
                summary="Finds Pets by status",\r
                description="Multiple status values can be provided with comma separated strings.",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="pet"\r
                )\r
        )\r
@@ -242,11 +226,10 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=DELETE,\r
+       @RestDelete(\r
                path="/pet/{petId}",\r
                summary="Deletes a pet",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="pet"\r
                )\r
        )\r
@@ -256,8 +239,7 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=DELETE,\r
+       @RestDelete(\r
                path="/pets",\r
                summary="Delete all pets",\r
                description="This can be done only by the logged in user."\r
@@ -276,9 +258,9 @@ public class PetStoreResource extends BasicRest implements PetStore {
         *\r
         * @return Store navigation page contents.\r
         */\r
-       @RestMethod(\r
+       @RestGet(\r
                summary="Store navigation page",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="store"\r
                )\r
        )\r
@@ -290,11 +272,10 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/store/order",\r
                summary="Petstore orders",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="store"\r
                )\r
        )\r
@@ -313,12 +294,11 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/store/order/{orderId}",\r
                summary="Find purchase order by ID",\r
                description="Returns a purchase order by ID.",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="store"\r
                )\r
        )\r
@@ -329,16 +309,15 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=POST,\r
+       @RestPost(\r
                path="/store/order",\r
                summary="Place an order for a pet",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="store"\r
-               ),\r
-               pojoSwaps={\r
-                       TemporalDateSwap.IsoLocalDate.class\r
-               }\r
+               )\r
+       )\r
+       @BeanConfig(\r
+               swaps = TemporalDateSwap.IsoLocalDate.class\r
        )\r
        public long placeOrder(long petId, String username) throws IdConflict, NotAcceptable, UnsupportedMediaType {\r
                CreateOrder co = new CreateOrder(petId, username);\r
@@ -346,15 +325,14 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=DELETE,\r
+       @RestDelete(\r
                path="/store/order/{orderId}",\r
                summary="Delete purchase order by ID",\r
                description= {\r
                        "For valid response try integer IDs with positive integer value.",\r
                        "Negative or non-integer values will generate API errors."\r
                },\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="store"\r
                )\r
        )\r
@@ -366,8 +344,7 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=DELETE,\r
+       @RestDelete(\r
                path="/orders",\r
                summary="Delete all orders",\r
                description="This can be done only by the logged in user."\r
@@ -378,12 +355,11 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/store/inventory",\r
                summary="Returns pet inventories by status",\r
                description="Returns a map of status codes to quantities",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="store",\r
                        responses={\r
                                "200:{ 'x-example':{AVAILABLE:123} }",\r
@@ -399,25 +375,23 @@ public class PetStoreResource extends BasicRest implements PetStore {
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/user",\r
                summary="Petstore users",\r
-               bpx="User: email,password,phone",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="user"\r
                )\r
        )\r
+       @Bean(on="User", excludeProperties="email,password,phone")\r
        public Collection<User> getUsers() throws NotAcceptable {\r
                return store.getUsers();\r
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/user/{username}",\r
                summary="Get user by user name",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="user"\r
                )\r
        )\r
@@ -426,12 +400,11 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=POST,\r
+       @RestPost(\r
                path="/user",\r
                summary="Create user",\r
                description="This can only be done by the logged in user.",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="user"\r
                )\r
        )\r
@@ -441,11 +414,10 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=POST,\r
+       @RestPost(\r
                path="/user/createWithArray",\r
                summary="Creates list of users with given input array",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="user"\r
                )\r
        )\r
@@ -456,12 +428,11 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=PUT,\r
+       @RestPut(\r
                path="/user/{username}",\r
                summary="Update user",\r
                description="This can only be done by the logged in user.",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="user"\r
                )\r
        )\r
@@ -471,12 +442,11 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=DELETE,\r
+       @RestDelete(\r
                path="/user/{username}",\r
                summary="Delete user",\r
                description="This can only be done by the logged in user.",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="user"\r
                )\r
        )\r
@@ -486,8 +456,7 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=DELETE,\r
+       @RestDelete(\r
                path="/users",\r
                summary="Delete all users",\r
                description="This can be done only by the admin."\r
@@ -498,18 +467,16 @@ public class PetStoreResource extends BasicRest implements PetStore {
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/user/login",\r
                summary="Logs user into the system",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="user"\r
                )\r
        )\r
        public Ok login(\r
                        String username,\r
                        String password,\r
-                       Value<Integer> rateLimit,\r
                        Value<ExpiresAfter> expiresAfter\r
                ) throws InvalidLogin, NotAcceptable {\r
 \r
@@ -520,17 +487,15 @@ public class PetStoreResource extends BasicRest implements PetStore {
 \r
                Date d = new Date(System.currentTimeMillis() + 30 * 60 * 1000);\r
                req.getSession().setAttribute("login-expires", d);\r
-               rateLimit.set(1000);\r
                expiresAfter.set(new ExpiresAfter(d));\r
                return OK;\r
        }\r
 \r
        @Override /* PetStore */\r
-       @RestMethod(\r
-               name=GET,\r
+       @RestGet(\r
                path="/user/logout",\r
                summary="Logs out current logged in user session",\r
-               swagger=@MethodSwagger(\r
+               swagger=@OpSwagger(\r
                        tags="user"\r
                )\r
        )\r
index a00c013e0ad8a9183a3f5a34741b4c51bae7ea31..069b037ab46a814b10431a15f2ed3d4398864e30 100755 (executable)
@@ -13,8 +13,9 @@
 package org.apache.juneau.petstore.rest;\r
 \r
 import org.apache.juneau.html.annotation.*;\r
-import org.apache.juneau.rest.*;\r
 import org.apache.juneau.rest.annotation.*;\r
+import org.apache.juneau.rest.config.*;\r
+import org.apache.juneau.rest.servlet.*;\r
 import org.apache.juneau.rest.widget.*;\r
 \r
 /**\r
@@ -37,7 +38,8 @@ import org.apache.juneau.rest.widget.*;
                ContentTypeMenuItem.class\r
        },\r
        navlinks={\r
-               "options: ?method=OPTIONS",\r
+               "api: servlet:/api",\r
+               "stats: servlet:/stats",\r
                "$W{ContentTypeMenuItem}",\r
                "source: $C{Source/gitHub}/org/apache/juneau/petstore/rest/$R{servletClassSimple}.java"\r
        },\r
@@ -52,6 +54,6 @@ import org.apache.juneau.rest.widget.*;
                "</div>"\r
        }\r
 )\r
-public class RootResources extends BasicRestServletGroup {\r
+public class RootResources extends BasicRestServletGroup implements BasicUniversalConfig {\r
        private static final long serialVersionUID = 1L;\r
 }\r
index 29a32446a56cc44fc6270c81cd0310eb5d462e25..0f120f66ee3c19772e2dff3e6779990678861304 100755 (executable)
@@ -3,8 +3,8 @@ package org.apache.juneau.petstore.test;
 import org.apache.juneau.petstore.App;
 import org.apache.juneau.petstore.dto.*;
 import org.apache.juneau.petstore.rest.PetStoreResource;
-import org.apache.juneau.rest.client2.*;
-import org.apache.juneau.rest.mock2.*;
+import org.apache.juneau.rest.client.*;
+import org.apache.juneau.rest.mock.*;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -39,8 +39,8 @@ public class MockTest {
                int petId = petStoreRest
                        .post("/pet", new CreatePet().name("Sunshine").price(100f).species(Species.BIRD).tags("nice"))
                        .run()
-                       .assertStatus().code().is(200)
-                       .getBody().as(int.class);
+                       .assertStatus().asCode().is(200)
+                       .getContent().as(int.class);
 
                return petId;
        }
@@ -49,7 +49,7 @@ public class MockTest {
                petStoreRest
                        .delete("/pets")
                        .complete()  // Use complete() because we're not consuming response.
-                       .assertStatus().code().is(200);
+                       .assertStatus().asCode().is(200);
        }
 
        // Delete pet by Id
@@ -60,7 +60,7 @@ public class MockTest {
                petStoreRest
                        .delete("/pet/" + petId)
                        .complete()
-                       .assertStatus().code().is(200);
+                       .assertStatus().asCode().is(200);
        }
 
        // Getting all pets
@@ -71,8 +71,8 @@ public class MockTest {
                petStoreRest
                        .get("/pet")
                        .run()
-                       .assertStatus().code().is(200)
-                       .assertBody().is("[{id:" + petId + ",species:'BIRD',name:'Sunshine',price:100.0,status:'AVAILABLE'}]");
+                       .assertStatus().asCode().is(200)
+                       .assertContent().is("[{id:" + petId + ",species:'BIRD',name:'Sunshine',price:100.0,status:'AVAILABLE'}]");
 
                deleteTestPets();
        }
@@ -84,7 +84,7 @@ public class MockTest {
                petStoreRest
                        .post("/pet", new CreatePet().name("Sunshine").price(100f).species(Species.BIRD).tags("nice"))
                        .complete()
-                       .assertStatus().code().is(200);
+                       .assertStatus().asCode().is(200);
 
                deleteTestPets();
        }
@@ -98,7 +98,7 @@ public class MockTest {
                        .get("/pet/" + petId)
                        .run()
                        .assertCode().is(200)
-                       .assertBody().is("{id:" + petId + ",species:'BIRD',name:'Sunshine',tags:['nice'],price:100.0,status:'AVAILABLE'}");
+                       .assertContent().is("{id:" + petId + ",species:'BIRD',name:'Sunshine',tags:['nice'],price:100.0,status:'AVAILABLE'}");
 
                deleteTestPets();
 
@@ -113,7 +113,7 @@ public class MockTest {
                        .get("/pet/findByStatus?status=AVAILABLE")
                        .run()
                        .assertCode().is(200)
-                       .assertBody().is("[{id:" + petId + ",species:'BIRD',name:'Sunshine',tags:['nice'],price:100.0,status:'AVAILABLE'}]");
+                       .assertContent().is("[{id:" + petId + ",species:'BIRD',name:'Sunshine',tags:['nice'],price:100.0,status:'AVAILABLE'}]");
 
                deleteTestPets();
        }
@@ -210,7 +210,7 @@ public class MockTest {
                        .get("/user")
                        .run()
                        .assertCode().is(200)
-                       .assertBody().is("[{username:'doglover',firstName:'Tom',lastName:'Simon',userStatus:'ACTIVE'}]");
+                       .assertContent().is("[{username:'doglover',firstName:'Tom',lastName:'Simon',userStatus:'ACTIVE'}]");
 
                deleteTestUsers();
        }
@@ -224,7 +224,7 @@ public class MockTest {
                        .get("/user/garfield")
                        .run()
                        .assertCode().is(200)
-                       .assertBody().is("{username:'garfield',firstName:'Tom',lastName:'Simon',userStatus:'ACTIVE'}");
+                       .assertContent().is("{username:'garfield',firstName:'Tom',lastName:'Simon',userStatus:'ACTIVE'}");
 
                deleteTestUsers();
        }
@@ -266,7 +266,7 @@ public class MockTest {
                        )
                        .run()
                        .assertCode().is(200)
-                       .getBody().as(int.class);
+                       .getContent().as(int.class);
 
                return orderId;
        }
@@ -296,7 +296,7 @@ public class MockTest {
                        .get("/store/order")
                        .run()
                        .assertCode().is(200)
-                       .assertBody().is("[{id:" + orderId + ",petId:0,status:'PLACED'}]");
+                       .assertContent().is("[{id:" + orderId + ",petId:0,status:'PLACED'}]");
 
                deleteTestOrders();
 
@@ -311,7 +311,7 @@ public class MockTest {
                        .get("/store/order/" + orderId)
                        .run()
                        .assertCode().is(200)
-                       .assertBody().is("{id:" + orderId + ",petId:0,status:'PLACED'}");
+                       .assertContent().is("{id:" + orderId + ",petId:0,status:'PLACED'}");
 
                deleteTestOrders();
        }
diff --git a/pom.xml b/pom.xml
index d99e287f0c60704cafc59759300d04e1329d4a27..1b6aba942d7869a6bb2edb85474e84785290875a 100755 (executable)
--- a/pom.xml
+++ b/pom.xml
@@ -36,7 +36,7 @@
                <maven.compiler.target>18</maven.compiler.target>
                
                <httpclient.version>4.5.6</httpclient.version>
-               <juneau.version>8.2.0</juneau.version>
+               <juneau.version>9.0-B1-SNAPSHOT</juneau.version>
                <derby.version>10.10.2.0</derby.version>
                <hibernate.version>5.0.9.Final</hibernate.version>
        </properties>