diff --git a/pom.xml b/pom.xml index 67cdfd2764885e648973164d9f6dd973578c0b5b..680a21923d59389a2cae130ddac7e4296d98435a 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,7 @@ <artifactId>spring-boot-starter-validation</artifactId> </dependency> + <!-- Data stores and supporting libs --> <dependency> <groupId>org.hsqldb</groupId> diff --git a/readme.md b/readme.md index 807b1c352a0f097ff5e082ab1ca8e59889e270ab..c52b4bb787ac1f7dfe8014bb459f0d884c815bf4 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# REST version of Spring PetClinic Sample Application (spring-framework-petclinic extend ) +# REST version of Spring PetClinic Sample Application (spring-framework-petclinic extension ) [](https://github.com/spring-petclinic/spring-petclinic-rest/actions/workflows/maven-build.yml) [](https://github.com/spring-petclinic/spring-petclinic-rest/actions/workflows/docker-build.yml) @@ -35,12 +35,62 @@ You can then access petclinic here: [http://localhost:9966/petclinic/](http://lo There is an actuator health check route as well: * [http://localhost:9966/petclinic/actuator/health](http://localhost:9966/petclinic/actuator/health) -## OpenAPI REST API documentation +## 📖 OpenAPI REST API Documentation +This project provides a RESTful API for managing a veterinary clinic's **owners, pets, veterinarians, visits, and specialties**. + +### **Access Swagger UI** +Swagger UI is available at: [http://localhost:9966/petclinic/swagger-ui.html](http://localhost:9966/petclinic/swagger-ui.html). + +API documentation (OAS 3.1) is accessible at: [http://localhost:9966/petclinic/v3/api-docs](http://localhost:9966/petclinic/v3/api-docs). + + +## 📌 API Endpoints Overview + +| **Method** | **Endpoint** | **Description** | +|-----------|------------|----------------| +| **Owners** | | | +| **GET** | `/api/owners` | Retrieve all pet owners | +| **GET** | `/api/owners/{ownerId}` | Get a pet owner by ID | +| **POST** | `/api/owners` | Add a new pet owner | +| **PUT** | `/api/owners/{ownerId}` | Update an owner’s details | +| **DELETE** | `/api/owners/{ownerId}` | Delete an owner | +| **GET** | `/api/owners/{ownerId}/pets/{petId}` | Get a pet by ID (owner’s pet) | +| **PUT** | `/api/owners/{ownerId}/pets/{petId}` | Update pet details (owner’s pet) | +| **POST** | `/api/owners/{ownerId}/pets` | Add a new pet to an owner | +| **POST** | `/api/owners/{ownerId}/pets/{petId}/visits` | Add a vet visit for a pet | +| **Pets** | | | +| **GET** | `/api/pets` | Retrieve all pets | +| **GET** | `/api/pets/{petId}` | Get a pet by ID | +| **POST** | `/api/pets` | Add a new pet | +| **PUT** | `/api/pets/{petId}` | Update pet details | +| **DELETE** | `/api/pets/{petId}` | Delete a pet | +| **Vets** | | | +| **GET** | `/api/vets` | Retrieve all veterinarians | +| **GET** | `/api/vets/{vetId}` | Get a vet by ID | +| **POST** | `/api/vets` | Add a new vet | +| **PUT** | `/api/vets/{vetId}` | Update vet details | +| **DELETE** | `/api/vets/{vetId}` | Delete a vet | +| **Pet Types** | | | +| **GET** | `/api/pettypes` | Retrieve all pet types | +| **GET** | `/api/pettypes/{petTypeId}` | Get a pet type by ID | +| **POST** | `/api/pettypes` | Add a new pet type | +| **PUT** | `/api/pettypes/{petTypeId}` | Update pet type details | +| **DELETE** | `/api/pettypes/{petTypeId}` | Delete a pet type | +| **Specialties** | | | +| **GET** | `/api/specialties` | Retrieve all vet specialties | +| **GET** | `/api/specialties/{specialtyId}` | Get a specialty by ID | +| **POST** | `/api/specialties` | Add a new specialty | +| **PUT** | `/api/specialties/{specialtyId}` | Update a specialty | +| **DELETE** | `/api/specialties/{specialtyId}` | Delete a specialty | +| **Visits** | | | +| **GET** | `/api/visits` | Retrieve all vet visits | +| **GET** | `/api/visits/{visitId}` | Get a visit by ID | +| **POST** | `/api/visits` | Add a new visit | +| **PUT** | `/api/visits/{visitId}` | Update a visit | +| **DELETE** | `/api/visits/{visitId}` | Delete a visit | +| **Users** | | | +| **POST** | `/api/users` | Create a new user | -You can reach the Swagger UI with this URL (after application start): -[http://localhost:9966/petclinic/](http://localhost:9966/petclinic/swagger-ui.html). - -You then can get the Open API description reaching this URL: [localhost:9966/petclinic/v3/api-docs](localhost:9966/petclinic/v3/api-docs). ## Screenshot of the Angular client @@ -61,7 +111,7 @@ A similar setup is provided for MySQL and PostgreSQL if a persistent database co Note that whenever the database type changes, the app needs to run with a different profile: `spring.profiles.active=mysql` for MySQL or `spring.profiles.active=postgres` for PostgreSQL. See the [Spring Boot documentation](https://docs.spring.io/spring-boot/how-to/properties-and-configuration.html#howto.properties-and-configuration.set-active-spring-profiles) for more detail on how to set the active profile. You can also change profile defined in the `application.properties` file. -For MySQL database, it is needed to change param `hsqldb` to `mysql` in the following line of `application.properies` file: +For MySQL database, it is needed to change param `hsqldb` to `mysql` in the following line of `application.properties` file: ```properties spring.profiles.active=hsqldb,spring-data-jpa ``` @@ -196,7 +246,7 @@ File -> Import -> Maven -> Existing Maven project ## Publishing a Docker image -This application uses [Google Jib]([https://github.com/GoogleContainerTools/jib) to build an optimized Docker image into the [Docker Hub](https://cloud.docker.com/u/springcommunity/repository/docker/springcommunity/spring-petclinic-rest/) repository. +This application uses [Google Jib](https://github.com/GoogleContainerTools/jib) to build an optimized Docker image into the [Docker Hub](https://cloud.docker.com/u/springcommunity/repository/docker/springcommunity/spring-petclinic-rest/) repository. The [pom.xml](pom.xml) has been configured to publish the image with a the `springcommunity/spring-petclinic-rest`image name. Command line to run: diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 460f9914afc865217dee048d01a9ff6c0305cbbc..a9bd37f77f5c837c8cb5e56d0a0df19bcba39f58 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -32,6 +32,10 @@ spring.sql.init.data-locations=classpath*:db/${database}/data.sql spring.messages.basename=messages/messages spring.jpa.open-in-view=false +# OpenAPI/Swagger UI (Defaults to true) +#springdoc.api-docs.enabled=true +#springdoc.swagger-ui.enabled=true + logging.level.org.springframework=INFO #logging.level.org.springframework=DEBUG